diff --git a/CMakeLists.txt b/CMakeLists.txt index 520536b..2d9f4aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,11 @@ set_property(TARGET VulkanHppGenerator PROPERTY CXX_STANDARD 11) target_include_directories(VulkanHppGenerator PRIVATE "${CMAKE_SOURCE_DIR}/tinyxml2") option (SAMPLES_BUILD OFF) - if (SAMPLES_BUILD) add_subdirectory(samples) -endif (SAMPLES_BUILD) \ No newline at end of file +endif (SAMPLES_BUILD) + +option (TESTS_BUILD OFF) +if (TESTS_BUILD) + add_subdirectory(tests) +endif (TESTS_BUILD) \ No newline at end of file diff --git a/README.md b/README.md index 6dabff4..20d1242 100644 --- a/README.md +++ b/README.md @@ -191,15 +191,22 @@ vk::StructureChain c = }; ``` -Sometimes the user has to pass a preallocated structure chain to query information. In those cases the corresponding query functions are variadic templates and do accept a structure chain to construct the return value: +Sometimes the user has to pass a preallocated structure chain to query information. For those cases there are two corresponding getter functions. One with a variadic template generating a structure chain of at least two elements to construct the return value: ``` -// Query vk::MemoryRequirements2KHR and vk::MemoryDedicatedRequirementsKHR when calling Device::getBufferMemoryRequirements2KHR: +// Query vk::MemoryRequirements2HR and vk::MemoryDedicatedRequirementsKHR when calling Device::getBufferMemoryRequirements2KHR: auto result = device.getBufferMemoryRequirements2KHR({}); vk::MemoryRequirements2KHR &memReqs = result.get(); vk::MemoryDedicatedRequirementsKHR &dedMemReqs = result.get(); ``` +To get just the base structure, without chaining, the other getter function provided does not need a template argument for the structure to get: + +``` +// Query just vk::MemoryRequirements2KHR +vk::MemoryRequirements2KHR memoryRequirements = device.getBufferMemoryRequirements2KHR({}); +``` + ### Return values, Error Codes & Exceptions By default Vulkan-Hpp has exceptions enabled. This means that Vulkan-Hpp checks the return code of each function call which returns a Vk::Result. If Vk::Result is a failure a std::runtime_error will be thrown. Since there is no need to return the error code anymore the C++ bindings can now return the actual desired return value, i.e. a vulkan handle. In those cases ResultValue ::type is defined as the returned type. diff --git a/Vulkan-Docs b/Vulkan-Docs index dd99197..9858c1e 160000 --- a/Vulkan-Docs +++ b/Vulkan-Docs @@ -1 +1 @@ -Subproject commit dd9919749a56177c2eb9b6525c0979722a3c24ff +Subproject commit 9858c1e89e21246f779226d2be779fd33bb6a50d diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index f9e4aaa..b4457ac 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -1,5260 +1,5340 @@ -// Copyright(c) 2015-2016, NVIDIA CORPORATION. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "VulkanHppGenerator.hpp" - -const std::string vkNamespace = R"( -#if !defined(VULKAN_HPP_NAMESPACE) -#define VULKAN_HPP_NAMESPACE vk -#endif - -#define VULKAN_HPP_STRINGIFY2(text) #text -#define VULKAN_HPP_STRINGIFY(text) VULKAN_HPP_STRINGIFY2(text) -#define VULKAN_HPP_NAMESPACE_STRING VULKAN_HPP_STRINGIFY(VULKAN_HPP_NAMESPACE) - -namespace VULKAN_HPP_NAMESPACE -{ -)"; - -const std::string constExprHeader = R"( -#if defined(_MSC_VER) && (_MSC_VER <= 1800) -# define VULKAN_HPP_CONSTEXPR -#else -# define VULKAN_HPP_CONSTEXPR constexpr -#endif -)"; - -const std::string exceptionHeader = R"( -#if defined(_MSC_VER) && (_MSC_VER == 1800) -# define noexcept _NOEXCEPT -#endif - - class ErrorCategoryImpl : public std::error_category - { - public: - virtual const char* name() const noexcept override { return VULKAN_HPP_NAMESPACE_STRING"::Result"; } - virtual std::string message(int ev) const override { return to_string(static_cast(ev)); } - }; - -#if defined(_MSC_VER) && (_MSC_VER == 1800) -# undef noexcept -#endif - - VULKAN_HPP_INLINE const std::error_category& errorCategory() - { - static ErrorCategoryImpl instance; - return instance; - } - - VULKAN_HPP_INLINE std::error_code make_error_code(Result e) - { - return std::error_code(static_cast(e), errorCategory()); - } - - VULKAN_HPP_INLINE std::error_condition make_error_condition(Result e) - { - return std::error_condition(static_cast(e), errorCategory()); - } -)"; - -const std::string exceptionClassesHeader = R"( -#if defined(_MSC_VER) && (_MSC_VER == 1800) -# define noexcept _NOEXCEPT -#endif - - class Error - { - public: - virtual ~Error() = default; - - virtual const char* what() const noexcept = 0; - }; - - class LogicError : public Error, public std::logic_error - { - public: - explicit LogicError( const std::string& what ) - : Error(), std::logic_error(what) {} - explicit LogicError( char const * what ) - : Error(), std::logic_error(what) {} - virtual ~LogicError() = default; - - virtual const char* what() const noexcept { return std::logic_error::what(); } - }; - - class SystemError : public Error, public std::system_error - { - public: - SystemError( std::error_code ec ) - : Error(), std::system_error(ec) {} - SystemError( std::error_code ec, std::string const& what ) - : Error(), std::system_error(ec, what) {} - SystemError( std::error_code ec, char const * what ) - : Error(), std::system_error(ec, what) {} - SystemError( int ev, std::error_category const& ecat ) - : Error(), std::system_error(ev, ecat) {} - SystemError( int ev, std::error_category const& ecat, std::string const& what) - : Error(), std::system_error(ev, ecat, what) {} - SystemError( int ev, std::error_category const& ecat, char const * what) - : Error(), std::system_error(ev, ecat, what) {} - virtual ~SystemError() = default; - - virtual const char* what() const noexcept { return std::system_error::what(); } - }; - -#if defined(_MSC_VER) && (_MSC_VER == 1800) -# undef noexcept -#endif - -)"; - -const std::string flagsHeader = R"( - template struct FlagTraits - { - enum { allFlags = 0 }; - }; - - template - class Flags - { - public: - VULKAN_HPP_CONSTEXPR Flags() - : m_mask(0) - { - } - - Flags(BitType bit) - : m_mask(static_cast(bit)) - { - } - - Flags(Flags const& rhs) - : m_mask(rhs.m_mask) - { - } - - explicit Flags(MaskType flags) - : m_mask(flags) - { - } - - Flags & operator=(Flags const& rhs) - { - m_mask = rhs.m_mask; - return *this; - } - - Flags & operator|=(Flags const& rhs) - { - m_mask |= rhs.m_mask; - return *this; - } - - Flags & operator&=(Flags const& rhs) - { - m_mask &= rhs.m_mask; - return *this; - } - - Flags & operator^=(Flags const& rhs) - { - m_mask ^= rhs.m_mask; - return *this; - } - - Flags operator|(Flags const& rhs) const - { - Flags result(*this); - result |= rhs; - return result; - } - - Flags operator&(Flags const& rhs) const - { - Flags result(*this); - result &= rhs; - return result; - } - - Flags operator^(Flags const& rhs) const - { - Flags result(*this); - result ^= rhs; - return result; - } - - bool operator!() const - { - return !m_mask; - } - - Flags operator~() const - { - Flags result(*this); - result.m_mask ^= FlagTraits::allFlags; - return result; - } - - bool operator==(Flags const& rhs) const - { - return m_mask == rhs.m_mask; - } - - bool operator!=(Flags const& rhs) const - { - return m_mask != rhs.m_mask; - } - - explicit operator bool() const - { - return !!m_mask; - } - - explicit operator MaskType() const - { - return m_mask; - } - - private: - MaskType m_mask; - }; - - template - Flags operator|(BitType bit, Flags const& flags) - { - return flags | bit; - } - - template - Flags operator&(BitType bit, Flags const& flags) - { - return flags & bit; - } - - template - Flags operator^(BitType bit, Flags const& flags) - { - return flags ^ bit; - } - -)"; - -const std::string optionalClassHeader = R"( - template - class Optional - { - public: - Optional(RefType & reference) { m_ptr = &reference; } - Optional(RefType * ptr) { m_ptr = ptr; } - Optional(std::nullptr_t) { m_ptr = nullptr; } - - operator RefType*() const { return m_ptr; } - RefType const* operator->() const { return m_ptr; } - explicit operator bool() const { return !!m_ptr; } - - private: - RefType *m_ptr; - }; -)"; - -const std::string arrayProxyHeader = R"( -#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE - template - class ArrayProxy - { - public: - VULKAN_HPP_CONSTEXPR ArrayProxy(std::nullptr_t) - : m_count(0) - , m_ptr(nullptr) - {} - - ArrayProxy(T & ptr) - : m_count(1) - , m_ptr(&ptr) - {} - - ArrayProxy(uint32_t count, T * ptr) - : m_count(count) - , m_ptr(ptr) - {} - - template - ArrayProxy(std::array::type, N> & data) - : m_count(N) - , m_ptr(data.data()) - {} - - template - ArrayProxy(std::array::type, N> const& data) - : m_count(N) - , m_ptr(data.data()) - {} - - template ::type>> - ArrayProxy(std::vector::type, Allocator> & data) - : m_count(static_cast(data.size())) - , m_ptr(data.data()) - {} - - template ::type>> - ArrayProxy(std::vector::type, Allocator> const& data) - : m_count(static_cast(data.size())) - , m_ptr(data.data()) - {} - - ArrayProxy(std::initializer_list const& data) - : m_count(static_cast(data.end() - data.begin())) - , m_ptr(data.begin()) - {} - - const T * begin() const - { - return m_ptr; - } - - const T * end() const - { - return m_ptr + m_count; - } - - const T & front() const - { - VULKAN_HPP_ASSERT(m_count && m_ptr); - return *m_ptr; - } - - const T & back() const - { - VULKAN_HPP_ASSERT(m_count && m_ptr); - return *(m_ptr + m_count - 1); - } - - bool empty() const - { - return (m_count == 0); - } - - uint32_t size() const - { - return m_count; - } - - T * data() const - { - return m_ptr; - } - - private: - uint32_t m_count; - T * m_ptr; - }; -#endif -)"; - -const std::string structureChainHeader = R"( - template struct isStructureChainValid { enum { value = false }; }; - - template - class StructureChainElement - { - public: - explicit operator Element&() { return value; } - explicit operator const Element&() const { return value; } - private: - Element value; - }; - - template - class StructureChain : private StructureChainElement... - { - public: - StructureChain() - { - link(); - } - - StructureChain(StructureChain const &rhs) - { - linkAndCopy(rhs); - } - - StructureChain(StructureElements const &... elems) - { - linkAndCopyElements(elems...); - } - - StructureChain& operator=(StructureChain const &rhs) - { - linkAndCopy(rhs); - return *this; - } - - template ClassType& get() { return static_cast(*this);} - - private: - template - void link() - { - } - - template - void link() - { - static_assert(isStructureChainValid::value, "The structure chain is not valid!"); - X& x = static_cast(*this); - Y& y = static_cast(*this); - x.pNext = &y; - link(); - } - - template - void linkAndCopy(StructureChain const &rhs) - { - static_cast(*this) = static_cast(rhs); - } - - template - void linkAndCopy(StructureChain const &rhs) - { - static_assert(isStructureChainValid::value, "The structure chain is not valid!"); - X& x = static_cast(*this); - Y& y = static_cast(*this); - x = static_cast(rhs); - x.pNext = &y; - linkAndCopy(rhs); - } - - template - void linkAndCopyElements(X const &xelem) - { - static_cast(*this) = xelem; - } - - template - void linkAndCopyElements(X const &xelem, Y const &yelem, Z const &... zelem) - { - static_assert(isStructureChainValid::value, "The structure chain is not valid!"); - X& x = static_cast(*this); - Y& y = static_cast(*this); - x = xelem; - x.pNext = &y; - linkAndCopyElements(yelem, zelem...); - } - }; - -)"; - -const std::string versionCheckHeader = R"( -#if !defined(VULKAN_HPP_HAS_UNRESTRICTED_UNIONS) -# if defined(__clang__) -# if __has_feature(cxx_unrestricted_unions) -# define VULKAN_HPP_HAS_UNRESTRICTED_UNIONS -# endif -# elif defined(__GNUC__) -# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -# if 40600 <= GCC_VERSION -# define VULKAN_HPP_HAS_UNRESTRICTED_UNIONS -# endif -# elif defined(_MSC_VER) -# if 1900 <= _MSC_VER -# define VULKAN_HPP_HAS_UNRESTRICTED_UNIONS -# endif -# endif -#endif -)"; - -const std::string inlineHeader = R"( -#if !defined(VULKAN_HPP_INLINE) -# if defined(__clang___) -# if __has_attribute(always_inline) -# define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__ -# else -# define VULKAN_HPP_INLINE inline -# endif -# elif defined(__GNUC__) -# define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__ -# elif defined(_MSC_VER) -# define VULKAN_HPP_INLINE inline -# else -# define VULKAN_HPP_INLINE inline -# endif -#endif -)"; - -const std::string explicitHeader = R"( -#if defined(VULKAN_HPP_TYPESAFE_CONVERSION) -# define VULKAN_HPP_TYPESAFE_EXPLICIT -#else -# define VULKAN_HPP_TYPESAFE_EXPLICIT explicit -#endif -)"; - -const std::string resultValueHeader = R"( - template - struct ResultValue - { - ResultValue( Result r, T & v ) - : result( r ) - , value( v ) - {} - - ResultValue( Result r, T && v ) - : result( r ) - , value( std::move( v ) ) - {} - - Result result; - T value; - - operator std::tuple() { return std::tuple(result, value); } - }; - - template - struct ResultValueType - { -#ifdef VULKAN_HPP_NO_EXCEPTIONS - typedef ResultValue type; -#else - typedef T type; -#endif - }; - - template <> - struct ResultValueType - { -#ifdef VULKAN_HPP_NO_EXCEPTIONS - typedef Result type; -#else - typedef void type; -#endif - }; -)"; - -const std::string createResultValueHeader = R"( - VULKAN_HPP_INLINE ResultValueType::type createResultValue( Result result, char const * message ) - { -#ifdef VULKAN_HPP_NO_EXCEPTIONS - VULKAN_HPP_ASSERT( result == Result::eSuccess ); - return result; -#else - if ( result != Result::eSuccess ) - { - throwResultException( result, message ); - } -#endif - } - - template - VULKAN_HPP_INLINE typename ResultValueType::type createResultValue( Result result, T & data, char const * message ) - { -#ifdef VULKAN_HPP_NO_EXCEPTIONS - VULKAN_HPP_ASSERT( result == Result::eSuccess ); - return ResultValue( result, data ); -#else - if ( result != Result::eSuccess ) - { - throwResultException( result, message ); - } - return std::move( data ); -#endif - } - - VULKAN_HPP_INLINE Result createResultValue( Result result, char const * message, std::initializer_list successCodes ) - { -#ifdef VULKAN_HPP_NO_EXCEPTIONS - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); -#else - if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) - { - throwResultException( result, message ); - } -#endif - return result; - } - - template - VULKAN_HPP_INLINE ResultValue createResultValue( Result result, T & data, char const * message, std::initializer_list successCodes ) - { -#ifdef VULKAN_HPP_NO_EXCEPTIONS - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); -#else - if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) - { - throwResultException( result, message ); - } -#endif - return ResultValue( result, data ); - } - -#ifndef VULKAN_HPP_NO_SMART_HANDLE - template - VULKAN_HPP_INLINE typename ResultValueType>::type createResultValue( Result result, T & data, char const * message, typename UniqueHandleTraits::deleter const& deleter ) - { -#ifdef VULKAN_HPP_NO_EXCEPTIONS - VULKAN_HPP_ASSERT( result == Result::eSuccess ); - return ResultValue>( result, UniqueHandle(data, deleter) ); -#else - if ( result != Result::eSuccess ) - { - throwResultException( result, message ); - } - return UniqueHandle(data, deleter); -#endif - } -#endif - -)"; - -const std::string uniqueHandleHeader = R"( -#ifndef VULKAN_HPP_NO_SMART_HANDLE - - template class UniqueHandleTraits; - - template - class UniqueHandle : public UniqueHandleTraits::deleter - { - private: - using Owner = typename UniqueHandleTraits::owner; - using Deleter = typename UniqueHandleTraits::deleter; - public: - explicit UniqueHandle( Type const& value = Type(), Deleter const& deleter = Deleter() ) - : Deleter( deleter) - , m_value( value ) - {} - - explicit UniqueHandle( Type const& value = Type(), Owner const& owner = Owner() ) - : Deleter( owner) - , m_value( value ) - {} - - UniqueHandle( UniqueHandle const& ) = delete; - - UniqueHandle( UniqueHandle && other ) - : Deleter( std::move( static_cast( other ) ) ) - , m_value( other.release() ) - {} - - ~UniqueHandle() - { - if ( m_value ) this->destroy( m_value ); - } - - UniqueHandle & operator=( UniqueHandle const& ) = delete; - - UniqueHandle & operator=( UniqueHandle && other ) - { - reset( other.release() ); - *static_cast(this) = std::move( static_cast(other) ); - return *this; - } - - explicit operator bool() const - { - return m_value.operator bool(); - } - - Type const* operator->() const - { - return &m_value; - } - - Type * operator->() - { - return &m_value; - } - - Type const& operator*() const - { - return m_value; - } - - Type & operator*() - { - return m_value; - } - - const Type & get() const - { - return m_value; - } - - Type & get() - { - return m_value; - } - - void reset( Type const& value = Type() ) - { - if ( m_value != value ) - { - if ( m_value ) this->destroy( m_value ); - m_value = value; - } - } - - Type release() - { - Type value = m_value; - m_value = nullptr; - return value; - } - - void swap( UniqueHandle & rhs ) - { - std::swap(m_value, rhs.m_value); - std::swap(static_cast(*this), static_cast(rhs)); - } - - private: - Type m_value; - }; - - template - VULKAN_HPP_INLINE void swap( UniqueHandle & lhs, UniqueHandle & rhs ) - { - lhs.swap( rhs ); - } -#endif - -)"; - -const std::string deleterClassString = R"( - struct AllocationCallbacks; - - template - class ObjectDestroy - { - public: - ObjectDestroy( OwnerType owner = OwnerType(), Optional allocator = nullptr, Dispatch const &dispatch = Dispatch() ) - : m_owner( owner ) - , m_allocator( allocator ) - , m_dispatch( &dispatch ) - {} - - OwnerType getOwner() const { return m_owner; } - Optional getAllocator() const { return m_allocator; } - - protected: - template - void destroy(T t) - { - m_owner.destroy( t, m_allocator, *m_dispatch ); - } - - private: - OwnerType m_owner; - Optional m_allocator; - Dispatch const* m_dispatch; - }; - - class NoParent; - - template - class ObjectDestroy - { - public: - ObjectDestroy( Optional allocator = nullptr, Dispatch const &dispatch = Dispatch() ) - : m_allocator( allocator ) - , m_dispatch( &dispatch ) - {} - - Optional getAllocator() const { return m_allocator; } - - protected: - template - void destroy(T t) - { - t.destroy( m_allocator, *m_dispatch ); - } - - private: - Optional m_allocator; - Dispatch const* m_dispatch; - }; - - template - class ObjectFree - { - public: - ObjectFree( OwnerType owner = OwnerType(), Optional allocator = nullptr, Dispatch const &dispatch = Dispatch() ) - : m_owner( owner ) - , m_allocator( allocator ) - , m_dispatch( &dispatch ) - {} - - OwnerType getOwner() const { return m_owner; } - Optional getAllocator() const { return m_allocator; } - - protected: - template - void destroy(T t) - { - m_owner.free( t, m_allocator, *m_dispatch ); - } - - private: - OwnerType m_owner; - Optional m_allocator; - Dispatch const* m_dispatch; - }; - - template - class PoolFree - { - public: - PoolFree( OwnerType owner = OwnerType(), PoolType pool = PoolType(), Dispatch const &dispatch = Dispatch() ) - : m_owner( owner ) - , m_pool( pool ) - , m_dispatch( &dispatch ) - {} - - OwnerType getOwner() const { return m_owner; } - PoolType getPool() const { return m_pool; } - - protected: - template - void destroy(T t) - { - m_owner.free( m_pool, t, *m_dispatch ); - } - - private: - OwnerType m_owner; - PoolType m_pool; - Dispatch const* m_dispatch; - }; - -)"; - - -std::string replaceWithMap(std::string const &input, std::map replacements) -{ - // This will match ${someVariable} and contain someVariable in match group 1 - std::regex re(R"(\$\{([^\}]+)\})"); - auto it = std::sregex_iterator(input.begin(), input.end(), re); - auto end = std::sregex_iterator(); - - // No match, just return the original string - if (it == end) - { - return input; - } - - std::string result = ""; - while (it != end) - { - std::smatch match = *it; - auto itReplacement = replacements.find(match[1].str()); - assert(itReplacement != replacements.end()); - - result += match.prefix().str() + ((itReplacement != replacements.end()) ? itReplacement->second : match[0].str()); - ++it; - - // we've passed the last match. Append the rest of the orignal string - if (it == end) - { - result += match.suffix().str(); - } - } - return result; -} - - -bool beginsWith(std::string const& text, std::string const& prefix); -void checkAttributes(std::map const& attributes, int line, std::map> const& required, std::map> const& optional); -void checkElements(std::vector const& elements, std::set const& values); -void checkEmptyElement(tinyxml2::XMLElement const* element); -void checkOrderedElements(std::vector const& elements, std::vector const& values); -std::string createEnumValueName(std::string const& name, std::string const& prefix, std::string const& postfix, bool bitmask, std::string const& tag); -bool endsWith(std::string const& text, std::string const& postfix); -void enterProtect(std::ostream &os, std::string const& protect); -std::string extractTag(std::string const& name); -std::string findTag(std::string const& name, std::set const& tags); -std::string generateEnumNameForFlags(std::string const& name); -std::map getAttributes(tinyxml2::XMLElement const* element); -std::vector getChildElements(tinyxml2::XMLElement const* element); -bool isErrorEnum(std::string const& enumName); -void leaveProtect(std::ostream &os, std::string const& protect); -std::string readArraySize(tinyxml2::XMLNode const* node, std::string& name); -std::string startUpperCase(std::string const& input); -std::string startLowerCase(std::string const& input); -std::string strip(std::string const& value, std::string const& prefix, std::string const& postfix = std::string()); -std::string stripErrorEnumPrefix(std::string const& enumName); -std::string stripPluralS(std::string const& name); -std::vector tokenize(std::string tokenString, char separator); -std::string trim(std::string const& input); -std::string trimEnd(std::string const& input); -std::string toCamelCase(std::string const& value); -std::string toUpperCase(std::string const& name); -void writeFunctionHeaderName(std::ostream & os, std::string const& name, bool singular, bool unique); -void writeReinterpretCast(std::ostream & os, bool leadingConst, bool vulkanType, std::string const& type, bool trailingPointerToConst); -void writeStandardOrEnhanced(std::ostream & os, std::string const& standard, std::string const& enhanced); -void writeTypesafeCheck(std::ostream & os, std::string const& typesafeCheck); -void writeVersionCheck(std::ostream & os, std::string const& version); -#if !defined(NDEBUG) -void skipFeatureRequire(tinyxml2::XMLElement const* element); -void skipImplicitExternSyncParams(tinyxml2::XMLElement const* element); -void skipTypeEnum(tinyxml2::XMLElement const* element, std::map const& attributes); -void skipTypeInclude(tinyxml2::XMLElement const* element); -#endif - -bool beginsWith(std::string const& text, std::string const& prefix) -{ - return !prefix.empty() && text.substr(0, prefix.length()) == prefix; -} - -// check the validity of an attributes map -// attributes : the map of name/value pairs of the encountered attributes -// line : the line in the xml file where the attributes are listed -// required : the required attributes, with a set of allowed values per attribute -// optional : the optional attributes, with a set of allowed values per attribute -void checkAttributes(std::map const& attributes, int line, std::map> const& required, std::map> const& optional) -{ - std::stringstream ss; - ss << line; - std::string lineNumber = ss.str(); - - // check if all required attributes are included and if there is a set of allowed values, check if the actual value is part of that set - for (auto const& r : required) - { - auto attributesIt = attributes.find(r.first); - if (attributesIt == attributes.end()) - { - throw std::runtime_error("Spec error on line " + lineNumber + ": missing attribute <" + r.first + ">"); - } - if (!r.second.empty() && (r.second.find(attributesIt->second) == r.second.end())) - { - throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected attribute value <" + attributesIt->second + "> in attribute <" + r.first + ">"); - } - } - // check if all not required attributes or optional, and if there is a set of allowed values, check if the actual value is part of that set - for (auto const& a : attributes) - { - if (required.find(a.first) == required.end()) - { - auto optionalIt = optional.find(a.first); - if (optionalIt == optional.end()) - { - std::cerr << "warning: " << "Unknown attribute " + a.first + " in line " + lineNumber + "!" << std::endl; - continue; - } - if (!optionalIt->second.empty()) - { - std::vector values = tokenize(a.second, ','); - for (auto const& v : values) - { - if (optionalIt->second.find(v) == optionalIt->second.end()) - { - throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected attribute value <" + v + "> in attribute <" + a.first + ">"); - } - } - } - } - } -} - -void checkElements(std::vector const& elements, std::set const& values) -{ - for (auto e : elements) - { - if (values.find(e->Value()) == values.end()) - { - std::stringstream ss; - ss << e->GetLineNum(); - std::string lineNumber = ss.str(); - std::cerr << "warning: Unknown element in spec on line: " << lineNumber << " " << e->Value() << "!" << std::endl; - } - } -} - -void checkEmptyElement(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); - checkElements(getChildElements(element), {}); -} - -void checkOrderedElements(std::vector const& elements, std::vector const& values) -{ - for (size_t i = 0; i < elements.size(); i++) - { - std::stringstream ss; - ss << elements[i]->GetLineNum(); - std::string lineNumber = ss.str(); - - if (values.size() <= i) - { - throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected surplus element <" + elements[i]->Value() + ">"); - } - if (values[i] != elements[i]->Value()) - { - throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected element <" + elements[i]->Value() + ">, expected <" + values[i] + ">"); - } - } -} - -std::string createEnumValueName(std::string const& name, std::string const& prefix, std::string const& postfix, bool bitmask, std::string const& tag) -{ - std::string result = "e" + toCamelCase(strip(name, prefix, postfix)); - if (bitmask) - { - size_t pos = result.find("Bit"); - if (pos != std::string::npos) - { - result.erase(pos, 3); - } - } - if (!tag.empty() && (result.substr(result.length() - tag.length()) == toCamelCase(tag))) - { - result = result.substr(0, result.length() - tag.length()) + tag; - } - return result; -} - -bool endsWith(std::string const& text, std::string const& postfix) -{ - return !postfix.empty() && (postfix.length() < text.length()) && (text.substr(text.length() - postfix.length()) == postfix); -} - -void enterProtect(std::ostream &os, std::string const& protect) -{ - if (!protect.empty()) - { - os << "#ifdef " << protect << std::endl; - } -} - -std::string extractTag(std::string const& name) -{ - // the name is supposed to look like: VK__ - size_t start = name.find('_'); - assert((start != std::string::npos) && (name.substr(0, start) == "VK")); - size_t end = name.find('_', start + 1); - assert(end != std::string::npos); - return name.substr(start + 1, end - start - 1); -} - -std::string findTag(std::string const& name, std::set const& tags) -{ - // find the tag in a name, return that tag or an empty string - auto tagIt = std::find_if(tags.begin(), tags.end(), [&name](std::string const& t) - { - size_t pos = name.find(t); - return (pos != std::string::npos) && (pos == name.length() - t.length()); - }); - return tagIt != tags.end() ? *tagIt : ""; -} - -std::string generateEnumNameForFlags(std::string const& name) -{ - // create a string, where the substring "Flags" is replaced by "FlagBits" - std::string generatedName = name; - size_t pos = generatedName.rfind("Flags"); - assert(pos != std::string::npos); - generatedName.replace(pos, 5, "FlagBits"); - return generatedName; -} - -std::map getAttributes(tinyxml2::XMLElement const* element) -{ - std::map attributes; - for (auto attribute = element->FirstAttribute(); attribute; attribute = attribute->Next()) - { - assert(attributes.find(attribute->Name()) == attributes.end()); - attributes[attribute->Name()] = attribute->Value(); - } - return attributes; -} - -std::vector getChildElements(tinyxml2::XMLElement const* element) -{ - std::vector childElements; - for (tinyxml2::XMLElement const* childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) - { - childElements.push_back(childElement); - } - return childElements; -} - -bool isErrorEnum(std::string const& enumName) -{ - return (enumName.substr(0, 6) == "eError"); -} - -void leaveProtect(std::ostream &os, std::string const& protect) -{ - if (!protect.empty()) - { - os << "#endif /*" << protect << "*/" << std::endl; - } -} - -std::string readArraySize(tinyxml2::XMLNode const* node, std::string& name) -{ - std::string arraySize; - if (name.back() == ']') - { - // if the parameter has '[' and ']' in its name, get the stuff inbetween those as the array size and erase that part from the parameter name - assert(!node->NextSibling()); - size_t pos = name.find('['); - assert(pos != std::string::npos); - arraySize = name.substr(pos + 1, name.length() - 2 - pos); - name.erase(pos); - } - else - { - // otherwise look for a sibling of this node - node = node->NextSibling(); - if (node && node->ToText()) - { - assert(node->Value()); - std::string value = trimEnd(node->Value()); - if (value == "[") - { - // if this node has '[' as its value, the next node holds the array size, and the node after that needs to hold ']', and there should be no more siblings - node = node->NextSibling(); - assert(node && node->ToElement() && (strcmp(node->Value(), "enum") == 0)); - arraySize = node->ToElement()->GetText(); - node = node->NextSibling(); - assert(node && node->ToText() && (trimEnd(node->Value()) == "]")); - } - else - { - // otherwise, the node holds '[' and ']', so get the stuff in between those as the array size - assert((value.front() == '[') && (value.back() == ']')); - arraySize = value.substr(1, value.length() - 2); - } - assert(!node->NextSibling() || ((strcmp(node->NextSibling()->Value(), "comment") == 0) && !node->NextSibling()->NextSibling())); - } - } - return arraySize; -} - -std::string startUpperCase(std::string const& input) -{ - return static_cast(toupper(input[0])) + input.substr(1); -} - -std::string startLowerCase(std::string const& input) -{ - return input.empty() ? "" : static_cast(tolower(input[0])) + input.substr(1); -} - -std::string strip(std::string const& value, std::string const& prefix, std::string const& postfix) -{ - std::string strippedValue = value; - if (beginsWith(strippedValue, prefix)) - { - strippedValue.erase(0, prefix.length()); - } - if (endsWith(strippedValue, postfix)) - { - strippedValue.erase(strippedValue.length() - postfix.length()); - } - return strippedValue; -} - -std::string stripErrorEnumPrefix(std::string const& enumName) -{ - assert(isErrorEnum(enumName)); - return strip(enumName, "eError"); -} - -std::string stripPluralS(std::string const& name) -{ - std::string strippedName(name); - size_t pos = strippedName.rfind('s'); - assert(pos != std::string::npos); - strippedName.erase(pos, 1); - return strippedName; -} - -std::vector tokenize(std::string tokenString, char separator) -{ - std::vector tokens; - size_t start = 0, end; - do - { - end = tokenString.find(separator, start); - tokens.push_back(tokenString.substr(start, end - start)); - start = end + 1; - } while (end != std::string::npos); - return tokens; -} - -std::string trim(std::string const& input) -{ - std::string result = input; - result.erase(result.begin(), std::find_if(result.begin(), result.end(), [](char c) { return !std::isspace(c); })); - result.erase(std::find_if(result.rbegin(), result.rend(), [](char c) { return !std::isspace(c); }).base(), result.end()); - return result; -} - -std::string trimEnd(std::string const& input) -{ - std::string result = input; - result.erase(std::find_if(result.rbegin(), result.rend(), [](char c) { return !std::isspace(c); }).base(), result.end()); - return result; -} - -std::string toCamelCase(std::string const& value) -{ - assert(!value.empty() && (isupper(value[0]) || isdigit(value[0]))); - std::string result; - result.reserve(value.size()); - result.push_back(value[0]); - for (size_t i = 1; i < value.size(); i++) - { - if (value[i] != '_') - { - if ((value[i - 1] == '_') || isdigit(value[i - 1])) - { - result.push_back(value[i]); - } - else - { - result.push_back(static_cast(tolower(value[i]))); - } - } - } - return result; -} - -std::string toUpperCase(std::string const& name) -{ - std::string convertedName; - - for (size_t i = 0; i(toupper(name[i]))); - } - return convertedName; -} - -void writeFunctionHeaderName(std::ostream & os, std::string const& name, bool singular, bool unique) -{ - os << (singular ? stripPluralS(name) : name); - if (unique) - { - os << "Unique"; - } -} - -void writeReinterpretCast(std::ostream & os, bool leadingConst, bool vulkanType, std::string const& type, bool trailingPointerToConst) -{ - os << "reinterpret_cast<"; - if (leadingConst) - { - os << "const "; - } - if (vulkanType) - { - os << "Vk"; - } - os << type; - if (trailingPointerToConst) - { - os << "* const"; - } - os << "*>"; -} - -void writeStandardOrEnhanced(std::ostream & os, std::string const& standard, std::string const& enhanced) -{ - if (standard == enhanced) - { - // standard and enhanced string are equal -> just use one of them and we're done - os << standard; - } - else - { - // standard and enhanced string differ -> use both, wrapping the enhanced by !VULKAN_HPP_DISABLE_ENHANCED_MODE - // determine the argument list of that standard, and compare it with that of the enhanced - // if they are equal -> need to have just one; if they differ -> need to have both - size_t standardStart = standard.find('('); - size_t standardCount = standard.find(')', standardStart) - standardStart; - size_t enhancedStart = enhanced.find('('); - bool unchangedInterface = (standard.substr(standardStart, standardCount) == enhanced.substr(enhancedStart, standardCount)); - if (unchangedInterface) - { - os << "#ifdef VULKAN_HPP_DISABLE_ENHANCED_MODE" << std::endl; - } - os << standard - << (unchangedInterface ? "#else" : "#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE") << std::endl - << enhanced - << "#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/" << std::endl; - } -} - -void writeTypesafeCheck(std::ostream & os, std::string const& typesafeCheck) -{ - os << "// 32-bit vulkan is not typesafe for handles, so don't allow copy constructors on this platform by default." << std::endl - << "// To enable this feature on 32-bit platforms please define VULKAN_HPP_TYPESAFE_CONVERSION" << std::endl - << typesafeCheck << std::endl - << "# if !defined( VULKAN_HPP_TYPESAFE_CONVERSION )" << std::endl - << "# define VULKAN_HPP_TYPESAFE_CONVERSION" << std::endl - << "# endif" << std::endl - << "#endif" << std::endl; -} - -void writeVersionCheck(std::ostream & os, std::string const& version) -{ - os << "static_assert( VK_HEADER_VERSION == " << version << " , \"Wrong VK_HEADER_VERSION!\" );" << std::endl - << std::endl; -} - -#if !defined(NDEBUG) -void skipFeatureRequire(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), {}, { { "name",{} } }); - checkElements(getChildElements(element), {}); -} - -void skipImplicitExternSyncParams(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); - std::vector children = getChildElements(element); - checkOrderedElements(children, { "param" }); - checkEmptyElement(children[0]); -} - -void skipTypeEnum(tinyxml2::XMLElement const* element, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), { { "category",{ "enum" } } }, { { "alias", {} }, { "name",{} } }); - checkElements(getChildElements(element), {}); -} - -void skipTypeInclude(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), { { "category",{ "include" } } }, { { "name",{} } }); - std::vector children = getChildElements(element); - checkElements(children, { "name" }); - - for (auto child : children) - { - checkEmptyElement(child); - } -} -#endif - -template -void VulkanHppGenerator::checkAlias(std::map const& data, std::string const& name, int line) -{ - if (data.find(name) == data.end()) - { - std::stringstream ss; - ss << line; - std::string lineNumber = ss.str(); - - throw std::runtime_error("Spec error on line " + lineNumber + ": missing alias <" + name + ">"); - } -} - -bool VulkanHppGenerator::containsUnion(std::string const& type, std::map const& structs) -{ - // a simple recursive check if a type is or contains a union - std::map::const_iterator sit = structs.find(type); - bool found = (sit != structs.end()); - if (found) - { - found = sit->second.isUnion; - for (std::vector::const_iterator mit = sit->second.members.begin(); mit != sit->second.members.end() && !found; ++mit) - { - found = (mit->type == mit->pureType) && containsUnion(mit->type, structs); - } - } - return found; -} - -std::map VulkanHppGenerator::createDefaults() -{ - std::map defaultValues; - for (auto dependency : m_dependencies) - { - assert(defaultValues.find(dependency.name) == defaultValues.end()); - switch (dependency.category) - { - case DependencyData::Category::BITMASK: - case DependencyData::Category::HANDLE: - case DependencyData::Category::STRUCT: - case DependencyData::Category::UNION: // just call the default constructor for bitmasks, handles, structs, and unions (which are mapped to classes) - defaultValues[dependency.name] = dependency.name + "()"; - break; - case DependencyData::Category::COMMAND: // commands should never be asked for defaults - break; - case DependencyData::Category::ENUM: - assert(m_enums.find(dependency.name) != m_enums.end()); - setDefault(dependency.name, defaultValues, m_enums.find(dependency.name)->second); - break; - case DependencyData::Category::FUNC_POINTER: // func_pointers default to nullptr - defaultValues[dependency.name] = "nullptr"; - break; - case DependencyData::Category::REQUIRED: // all required default to "0" - case DependencyData::Category::SCALAR: // all scalars default to "0" - defaultValues[dependency.name] = "0"; - break; - default: - assert(false && "Unhandled exception category"); - break; - } - } - return defaultValues; -} - -void VulkanHppGenerator::determineEnhancedReturnType(CommandData & commandData) -{ - std::string returnType; - // if there is a return parameter of type void or Result, and if it's of type Result it either has just one success code - // or two success codes, where the second one is of type eIncomplete and it's a two-step process - // -> we can return that parameter - if ((commandData.returnParam != ~0) - && ((commandData.returnType == "void") - || ((commandData.returnType == "Result") - && ((commandData.successCodes.size() == 1) - || ((commandData.successCodes.size() == 2) - && (commandData.successCodes[1] == "eIncomplete") - && commandData.twoStep))))) - { - if (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end()) - { - // the return parameter is a vector-type parameter - if (commandData.params[commandData.returnParam].pureType == "void") - { - // for a vector of void, we use a vector of uint8_t, instead - commandData.enhancedReturnType = "std::vector"; - } - else - { - // for the other parameters, we use a vector of the pure type - commandData.enhancedReturnType = "std::vector<" + commandData.params[commandData.returnParam].pureType + ",Allocator>"; - } - } - else - { - // it's a simple parameter -> get the type and just remove the trailing '*' (originally, it's a pointer) - assert(commandData.params[commandData.returnParam].type.back() == '*'); - assert(commandData.params[commandData.returnParam].type.find("const") == std::string::npos); - commandData.enhancedReturnType = commandData.params[commandData.returnParam].type; - commandData.enhancedReturnType.pop_back(); - } - } - else if ((commandData.returnType == "Result") && (commandData.successCodes.size() == 1)) - { - // an original return of type "Result" with just one successCode is changed to void, errors throw an exception - commandData.enhancedReturnType = "void"; - } - else - { - // the return type just stays the original return type - commandData.enhancedReturnType = commandData.returnType; - } -} - -void VulkanHppGenerator::determineReducedName(CommandData & commandData) -{ - commandData.reducedName = commandData.fullName; - std::string searchName = commandData.params[0].pureType; - size_t pos = commandData.fullName.find(searchName); - if ((pos == std::string::npos) && isupper(searchName[0])) - { - searchName[0] = static_cast(tolower(searchName[0])); - pos = commandData.fullName.find(searchName); - } - if (pos != std::string::npos) - { - commandData.reducedName.erase(pos, searchName.length()); - } - else if ((searchName == "commandBuffer") && (commandData.fullName.find("cmd") == 0)) - { - commandData.reducedName.erase(0, 3); - pos = 0; - } - if ((pos == 0) && isupper(commandData.reducedName[0])) - { - commandData.reducedName[0] = static_cast(tolower(commandData.reducedName[0])); - } -} - -void VulkanHppGenerator::determineReturnParam(CommandData & commandData) -{ - // for return types of type Result or void, we can replace determine a parameter to return - if ((commandData.returnType == "Result") || (commandData.returnType == "void")) - { - for (size_t i = 0; i < commandData.params.size(); i++) - { - if ((commandData.params[i].type.find('*') != std::string::npos) - && (commandData.params[i].type.find("const") == std::string::npos) - && std::find_if(commandData.vectorParams.begin(), commandData.vectorParams.end(), [i](std::pair const& vp) { return vp.second == i; }) == commandData.vectorParams.end() - && ((commandData.vectorParams.find(i) == commandData.vectorParams.end()) || commandData.twoStep || (commandData.successCodes.size() == 1))) - { - // it's a non-const pointer, not a vector-size parameter, if it's a vector parameter, its a two-step process or there's just one success code - // -> look for another non-cost pointer argument - auto paramIt = std::find_if(commandData.params.begin() + i + 1, commandData.params.end(), [](ParamData const& pd) - { - return (pd.type.find('*') != std::string::npos) && (pd.type.find("const") == std::string::npos); - }); - // if there is another such argument, we can't decide which one to return -> return none (~0) - // otherwise return the index of the selcted parameter - commandData.returnParam = paramIt != commandData.params.end() ? ~0 : i; - } - } - } -} - -void VulkanHppGenerator::determineSkippedParams(CommandData & commandData) -{ - // the size-parameters of vector parameters are not explicitly used in the enhanced API - std::for_each(commandData.vectorParams.begin(), commandData.vectorParams.end(), [&commandData](std::pair const& vp) { if (vp.second != ~0) commandData.skippedParams.insert(vp.second); }); - // and the return parameter is also skipped - if (commandData.returnParam != ~0) - { - commandData.skippedParams.insert(commandData.returnParam); - } -} - -void VulkanHppGenerator::determineTemplateParam(CommandData & commandData) -{ - for (size_t i = 0; i < commandData.params.size(); i++) - { - // any vector parameter on the pure type void is templatized in the enhanced API - if ((commandData.vectorParams.find(i) != commandData.vectorParams.end()) && (commandData.params[i].pureType == "void")) - { -#if !defined(NDEBUG) - for (size_t j = i + 1; j < commandData.params.size(); j++) - { - assert((commandData.vectorParams.find(j) == commandData.vectorParams.end()) || (commandData.params[j].pureType != "void")); - } -#endif - commandData.templateParam = i; - break; - } - } - assert((commandData.templateParam == ~0) || (commandData.vectorParams.find(commandData.templateParam) != commandData.vectorParams.end())); -} - -void VulkanHppGenerator::determineVectorParams(CommandData & commandData) -{ - // look for the parameters whose len equals the name of an other parameter - for (auto it = commandData.params.begin(), begin = it, end = commandData.params.end(); it != end; ++it) - { - if (!it->len.empty()) - { - auto findLambda = [it](ParamData const& pd) { return pd.name == it->len; }; - auto findIt = std::find_if(begin, it, findLambda); // look for a parameter named as the len of this parameter - assert((std::count_if(begin, end, findLambda) == 0) || (findIt < it)); // make sure, there is no other parameter like that - - // add this parameter as a vector parameter, using the len-name parameter as the second value (or ~0 if there is nothing like that) - commandData.vectorParams.insert(std::make_pair(std::distance(begin, it), findIt < it ? std::distance(begin, findIt) : ~0)); - assert((commandData.vectorParams[std::distance(begin, it)] != ~0) - || (it->len == "null-terminated") - || (it->len == "pAllocateInfo::descriptorSetCount") - || (it->len == "pAllocateInfo::commandBufferCount")); - } - } -} - -std::string VulkanHppGenerator::generateCall(CommandData const& commandData, bool firstCall, bool singular) -{ - std::ostringstream call; - writeCall(call, commandData, firstCall, singular); - return call.str(); -} - -std::string const& VulkanHppGenerator::getTypesafeCheck() const -{ - return m_typesafeCheck; -} - -std::string const& VulkanHppGenerator::getVersion() const -{ - return m_version; -} - -std::string const& VulkanHppGenerator::getVulkanLicenseHeader() const -{ - return m_vulkanLicenseHeader; -} - -bool VulkanHppGenerator::isSubStruct(std::pair const& nsd, std::string const& name, StructData const& structData) -{ - if ((nsd.first != name) && (nsd.second.members.size() < structData.members.size()) && (structData.members[0].name != "sType")) - { - bool equal = true; - for (size_t i = 0; i < nsd.second.members.size() && equal; i++) - { - equal = (nsd.second.members[i].type == structData.members[i].type) && (nsd.second.members[i].name == structData.members[i].name); - } - if (equal) - { - return true; - } - } - return false; -} - -void VulkanHppGenerator::linkCommandToHandle(CommandData & commandData) -{ - // first, find the handle named like the type of the first argument - // if there is no such handle, look for the unnamed "handle", that gathers all the functions not tied to a specific handle - assert(!commandData.params.empty()); - std::map::iterator hit = m_handles.find(commandData.params[0].pureType); - if (hit == m_handles.end()) - { - hit = m_handles.find(""); - } - assert(hit != m_handles.end()); - - // put the command into the handle's list of commands, and store the handle in the commands className - hit->second.commands.push_back(commandData.fullName); - commandData.className = hit->first; - - // add the dependencies of the command to the dependencies of the handle - DependencyData const& commandDD = m_dependencies.back(); - std::list::iterator handleDD = std::find_if(m_dependencies.begin(), m_dependencies.end(), [hit](DependencyData const& dd) { return dd.name == hit->first; }); - assert((handleDD != m_dependencies.end()) || hit->first.empty()); - if (handleDD != m_dependencies.end()) - { - std::copy_if(commandDD.dependencies.begin(), commandDD.dependencies.end(), std::inserter(handleDD->dependencies, handleDD->dependencies.end()), [hit](std::string const& d) { return d != hit->first; }); - } -} - -bool VulkanHppGenerator::readCommandParam(tinyxml2::XMLElement const* element, std::set & dependencies, std::vector & params) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), {}, { { "externsync",{} },{ "len",{} },{ "noautovalidity",{ "true" } },{ "optional",{ "false", "true" } } }); - checkElements(getChildElements(element), { "name", "type" }); - - ParamData param; - - bool isTwoStep = false; - auto lenAttribute = attributes.find("len"); - if (lenAttribute != attributes.end()) - { - param.len = lenAttribute->second; - auto pit = std::find_if(params.begin(), params.end(), [¶m](ParamData const& pd) { return param.len == pd.name; }); - if (pit != params.end()) - { - isTwoStep = (pit->type.find('*') != std::string::npos); - } - } - - // get the type of the parameter, and put it into the list of dependencies - tinyxml2::XMLNode const* child = readCommandParamType(element->FirstChild(), param); - dependencies.insert(param.pureType); - - assert(child->ToElement()); - tinyxml2::XMLElement const* nameElement = child->ToElement(); - checkEmptyElement(nameElement); - param.name = child->ToElement()->GetText(); - - param.arraySize = readArraySize(child, param.name); - - auto optionalAttribute = attributes.find("optional"); - param.optional = (optionalAttribute != attributes.end()) && (optionalAttribute->second == "true"); - - params.push_back(param); - - assert(!isTwoStep || (param.type.substr(0, 6) != "const ")); - return isTwoStep; -} - -tinyxml2::XMLNode const* VulkanHppGenerator::readCommandParamType(tinyxml2::XMLNode const* node, ParamData& param) -{ - assert(node); - if (node->ToText()) - { - // start type with "const" or "struct", if needed - std::string value = trim(node->Value()); - assert((value == "const") || (value == "struct") || (value == "const struct")); - param.type = value + " "; - node = node->NextSibling(); - assert(node); - } - - // get the pure type - assert(node->ToElement()); - tinyxml2::XMLElement const* typeElement = node->ToElement(); - checkEmptyElement(typeElement); - std::string type = strip(node->ToElement()->GetText(), "Vk"); - param.unchangedType = param.type + node->ToElement()->GetText(); - param.type += type; - param.pureType = type; - - // end with "*", "**", or "* const*", if needed - node = node->NextSibling(); - assert(node); - if (node->ToText()) - { - std::string value = trimEnd(node->Value()); - assert((value == "*") || (value == "**") || (value == "* const*")); - param.type += value; - param.unchangedType += value; - node = node->NextSibling(); - } - - return node; -} - -void VulkanHppGenerator::readCommands(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), {}, { { "comment",{} } }); - std::vector children = getChildElements(element); - checkElements(children, { "command" }); - - for (auto child : children) - { - readCommandsCommand(child); - } -} - -void VulkanHppGenerator::readCommandsCommand(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), {}, - { { "alias", {} }, - { "cmdbufferlevel",{ "primary", "secondary" } }, - { "comment",{} }, - { "errorcodes",{} }, - { "name", {} }, - { "pipeline",{ "compute", "graphics", "transfer" } }, - { "queues",{ "compute", "graphics", "sparse_binding", "transfer" } }, - { "renderpass",{ "both", "inside", "outside" } }, - { "successcodes",{} } - }); - std::vector children = getChildElements(element); - - CommandData commandData; - auto aliasIt = attributes.find("alias"); - if (aliasIt != attributes.end()) - { - // for command aliases, create a copy of the aliased command - checkAttributes(attributes, element->GetLineNum(), { { "alias",{} },{ "name",{} } }, {}); // re-check on alias type! - checkElements(children, {}); - - std::string alias = startLowerCase(strip(aliasIt->second, "vk")); - checkAlias(m_commands, alias, element->GetLineNum()); - - auto commandsIt = m_commands.find(alias); - assert(commandsIt != m_commands.end()); - commandData = commandsIt->second; - commandData.fullName = startLowerCase(strip(attributes.find("name")->second, "vk")); - commandData.isAlias = true; - determineReducedName(commandData); - linkCommandToHandle(commandData); - - // add a DependencyData to this name - m_dependencies.push_back(DependencyData(DependencyData::Category::COMMAND, commandData.fullName)); - m_dependencies.back().dependencies.insert(alias); - } - else - { - checkElements(children, { "implicitexternsyncparams", "param", "proto" }); - - // read the success codes - auto successcodesAttribute = attributes.find("successcodes"); - if (successcodesAttribute != attributes.end()) - { - commandData.successCodes = tokenize(successcodesAttribute->second, ','); - for (auto & code : commandData.successCodes) - { - std::string tag = findTag(code, m_tags); - // on each success code: prepend 'e', strip "VK_" and a tag, convert it to camel case, and add the tag again - code = std::string("e") + toCamelCase(strip(code, "VK_", tag)) + tag; - } - } - - for (auto child : children) - { - std::string value = child->Value(); - if (value == "param") - { - commandData.twoStep |= readCommandParam(child, m_dependencies.back().dependencies, commandData.params); - } - else if (value == "proto") - { - readCommandProto(child, commandData.returnType, commandData.unchangedReturnType, commandData.fullName); - } -#if !defined(NDEBUG) - else - { - assert(value == "implicitexternsyncparams"); - skipImplicitExternSyncParams(child); - } -#endif - } - - determineReducedName(commandData); - linkCommandToHandle(commandData); - registerDeleter(commandData); - determineVectorParams(commandData); - determineReturnParam(commandData); - determineTemplateParam(commandData); - determineEnhancedReturnType(commandData); - determineSkippedParams(commandData); - } - - // insert the commandData into the commands-map, - assert(m_commands.find(commandData.fullName) == m_commands.end()); - m_commands.insert(std::make_pair(commandData.fullName, commandData)); -} - -void VulkanHppGenerator::readCommandProto(tinyxml2::XMLElement const* element, std::string & returnType, std::string & unchangedReturnType, std::string & fullName) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); - std::vector children = getChildElements(element); - checkOrderedElements(children, { "type", "name" }); - - // get return type and name of the command - returnType = strip(children[0]->GetText(), "Vk"); - unchangedReturnType = children[0]->GetText(); - fullName = startLowerCase(strip(children[1]->GetText(), "vk")); - - // add an empty DependencyData to this name - m_dependencies.push_back(DependencyData(DependencyData::Category::COMMAND, fullName)); -} - -void VulkanHppGenerator::readComment(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); - checkElements(getChildElements(element), {}); - - assert(element->GetText()); - std::string text = element->GetText(); - if (text.find("\nCopyright") == 0) - { - assert(m_vulkanLicenseHeader.empty()); - m_vulkanLicenseHeader = text; - - // erase the part after the Copyright text - size_t pos = m_vulkanLicenseHeader.find("\n\n------------------------------------------------------------------------"); - if (pos != std::string::npos) { - m_vulkanLicenseHeader.erase(pos); - } - - // replace any '\n' with "\n// " - for (pos = m_vulkanLicenseHeader.find('\n'); pos != std::string::npos; pos = m_vulkanLicenseHeader.find('\n', pos + 1)) - { - m_vulkanLicenseHeader.replace(pos, 1, "\n// "); - } - - // and add a little message on our own - m_vulkanLicenseHeader += "\n\n// This header is generated from the Khronos Vulkan XML API Registry."; - } - - m_vulkanLicenseHeader.erase(m_vulkanLicenseHeader.begin(), std::find_if(m_vulkanLicenseHeader.begin(), m_vulkanLicenseHeader.end(), [](char c) { return !std::isspace(c); })); -} - -void VulkanHppGenerator::readDisabledExtensionRequire(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); - std::vector children = getChildElements(element); - checkElements(children, { "command", "enum", "type" }); - - for (auto child : children) - { - checkElements(getChildElements(child), {}); - - std::string value = child->Value(); - if ((value == "command") || (value == "type")) - { - std::map attributes = getAttributes(child); - checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, {}); - - // disable a command or a type ! - auto nameAttribute = attributes.find("name"); - std::string name = (value == "command") ? startLowerCase(strip(nameAttribute->second, "vk")) : strip(nameAttribute->second, "Vk"); - - // search this name in the dependencies list and remove it - std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&name](DependencyData const& dd) { return(dd.name == name); }); - assert(depIt != m_dependencies.end()); - m_dependencies.erase(depIt); - - // erase it from all dependency sets - for (auto & dep : m_dependencies) - { - dep.dependencies.erase(name); - } - - if (value == "command") - { - // first unlink the command from its class - auto commandsIt = m_commands.find(name); - assert(commandsIt != m_commands.end()); - assert(!commandsIt->second.className.empty()); - auto handlesIt = m_handles.find(commandsIt->second.className); - assert(handlesIt != m_handles.end()); - auto it = std::find(handlesIt->second.commands.begin(), handlesIt->second.commands.end(), name); - assert(it != handlesIt->second.commands.end()); - handlesIt->second.commands.erase(it); - - // then remove the command - m_commands.erase(name); - } - else - { - // a type simply needs to be removed from the structs and vkTypes sets - assert((m_structs.find(name) != m_structs.end()) && (m_vkTypes.find(name) != m_vkTypes.end())); - m_structs.erase(name); - m_vkTypes.erase(name); - } - } - else - { - assert(value == "enum"); - std::map attributes = getAttributes(child); - checkAttributes(attributes, child->GetLineNum(), { { "name",{} } }, { { "bitpos", {} }, { "extends",{} },{ "offset",{} },{ "value",{} } }); - } - } -} - -void VulkanHppGenerator::readEnums(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { { "comment",{} },{ "type",{ "bitmask", "enum" } } }); - std::vector children = getChildElements(element); - checkElements(children, { "comment", "enum", "unused" }); - - std::string name = strip(attributes.find("name")->second, "Vk"); - - if (name == "API Constants") - { - for (auto child : children) - { - assert(strcmp(child->Value(), "enum") == 0); - readEnumsConstant(child); - } - } - else - { - checkAttributes(attributes, element->GetLineNum(), { { "name",{} },{ "type",{ "bitmask", "enum" } } }, { { "comment",{} } }); // re-check with type as required - - // add an empty DependencyData on this name into the dependencies list - m_dependencies.push_back(DependencyData(DependencyData::Category::ENUM, name)); - - // ad an empty EnumData on this name into the enums map - std::map::iterator it = m_enums.insert(std::make_pair(name, EnumData(name))).first; - - if (name == "Result") - { - // special handling for VKResult, as its enums just have VK_ in common - it->second.prefix = "VK_"; - } - else - { - std::string type = attributes.find("type")->second; - it->second.bitmask = (type == "bitmask"); - if (it->second.bitmask) - { - // for a bitmask enum, start with "VK", cut off the trailing "FlagBits", and convert that name to upper case - // end that with "Bit" - size_t pos = name.find("FlagBits"); - assert(pos != std::string::npos); - it->second.prefix = "VK" + toUpperCase(name.substr(0, pos)) + "_"; - } - else - { - // for a non-bitmask enum, start with "VK", and convert the name to upper case - it->second.prefix = "VK" + toUpperCase(name) + "_"; - } - - // if the enum name contains a tag move it from the prefix to the postfix to generate correct enum value names. - for (std::set::const_iterator tit = m_tags.begin(); tit != m_tags.end(); ++tit) - { - if ((tit->length() < it->second.prefix.length()) && (it->second.prefix.substr(it->second.prefix.length() - tit->length() - 1) == (*tit + "_"))) - { - it->second.prefix.erase(it->second.prefix.length() - tit->length() - 1); - it->second.postfix = "_" + *tit; - break; - } - else if ((tit->length() < it->second.name.length()) && (it->second.name.substr(it->second.name.length() - tit->length()) == *tit)) - { - it->second.postfix = "_" + *tit; - break; - } - } - } - - // read the names of the enum values - for (auto child : children) - { - std::string value = child->Value(); - if (value == "enum") - { - readEnumsEnum(child, it->second, ""); - } -#if !defined(NDEBUG) - else - { - assert((value == "comment") || (value == "unused")); - } -#endif - } - - // add this enum to the set of Vulkan data types - assert(m_vkTypes.find(name) == m_vkTypes.end()); - m_vkTypes.insert(name); - } -} - -void VulkanHppGenerator::readEnumsEnum(tinyxml2::XMLElement const* element, EnumData & enumData, std::string const& tag) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { {"alias", {} }, { "bitpos",{} },{ "comment",{} },{ "value",{} } }); - assert((attributes.find("alias") != attributes.end()) + (attributes.find("bitpos") != attributes.end()) + (attributes.find("value") != attributes.end()) == 1); - checkElements(getChildElements(element), {}); - auto aliasIt = attributes.find("alias"); - if (aliasIt != attributes.end()) - { - auto enumIt = std::find_if(enumData.values.begin(), enumData.values.end(), [&aliasIt](EnumValueData const& evd) { return evd.value == aliasIt->second; }); - assert((enumIt != enumData.values.end()) && enumIt->alias.empty()); - enumIt->alias = createEnumValueName(attributes.find("name")->second, enumData.prefix, enumData.postfix, enumData.bitmask, tag); - } - else - { - enumData.addEnumValue(attributes.find("name")->second, tag, m_nameMap); - } -} - -void VulkanHppGenerator::readEnumsConstant(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { { "alias", {}}, { "comment",{} }, { "value",{} } }); - checkElements(getChildElements(element), {}); - std::string name = attributes.find("name")->second; - assert(m_constants.find(name) == m_constants.end()); - - auto aliasIt = attributes.find("alias"); - if (aliasIt != attributes.end()) - { - checkAttributes(attributes, element->GetLineNum(), { {"alias", {}}, { "name", {}} }, {}); // re-check on alias type - checkAlias(m_constants, aliasIt->second, element->GetLineNum()); - m_constants[name] = m_constants.find(aliasIt->second)->second; - } - else - { - checkAttributes(attributes, element->GetLineNum(), { { "name",{} }, { "value", {}} }, { {"comment", {} } }); // re-check on non-alias type - m_constants[name] = attributes.find("value")->second; - } -} - -void VulkanHppGenerator::readExtensionCommand(tinyxml2::XMLElement const* element, std::string const& protect) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, {}); - checkElements(getChildElements(element), {}); - - // just add the protect string to the CommandData - if (!protect.empty()) - { - std::string name = startLowerCase(strip(attributes.find("name")->second, "vk")); - std::map::iterator cit = m_commands.find(name); - assert(cit != m_commands.end()); - cit->second.protect = protect; - } -} - -void VulkanHppGenerator::readExtensionEnum(tinyxml2::XMLElement const* element, std::string const& tag) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), - { - { "name", {} } - }, - { - { "alias", {} }, - { "bitpos", {} }, - { "comment", {} }, - { "dir", { "-" } }, - { "extends", {} }, - { "extnumber", {} }, - { "offset", {} }, - { "value", {} } - }); - checkElements(getChildElements(element), {}); - - // TODO process enums which don't extend existing enums - auto extendsIt = attributes.find("extends"); - if (extendsIt != attributes.end()) - { - std::string extends = strip(extendsIt->second, "Vk"); - auto enumIt = m_enums.find(extends); - assert(enumIt != m_enums.end()); - - auto aliasIt = attributes.find("alias"); - if (aliasIt != attributes.end()) - { - checkAttributes(attributes, element->GetLineNum(), { { "alias", {} }, { "extends", {} }, { "name", {} } }, { { "comment",{} } }); - std::string alias = createEnumValueName(aliasIt->second, enumIt->second.prefix, enumIt->second.postfix, enumIt->second.bitmask, tag); - auto evdIt = std::find_if(enumIt->second.values.begin(), enumIt->second.values.end(), [&alias](EnumValueData const& evd) { return evd.name == alias; }); - assert(evdIt != enumIt->second.values.end()); - evdIt->alias = createEnumValueName(attributes.find("name")->second, enumIt->second.prefix, enumIt->second.postfix, enumIt->second.bitmask, tag); - if (evdIt->name == evdIt->alias) - { - // skip alias, that would result in the very same enum name - evdIt->alias.clear(); - } - } - else - { - assert((attributes.find("bitpos") != attributes.end()) + (attributes.find("offset") != attributes.end()) + (attributes.find("value") != attributes.end()) == 1); - enumIt->second.addEnumValue(attributes.find("name")->second, tag, m_nameMap); - } - } -} - -void VulkanHppGenerator::readExtensionRequire(tinyxml2::XMLElement const* element, std::string const& protect, std::string const& tag) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), {}, { { "extension",{} },{ "feature",{} } }); - std::vector children = getChildElements(element); - checkElements(children, { "command", "comment", "enum", "type" }); - - for (auto child : children) - { - std::string value = child->Value(); - - if (value == "command") - { - readExtensionCommand(child, protect); - } - else if (value == "enum") - { - readExtensionEnum(child, tag); - } - else if (value == "type") - { - readExtensionType(child, protect); - } -#if !defined(NDEBUG) - else - { - assert(value == "comment"); - checkEmptyElement(child); - } -#endif - } -} - -void VulkanHppGenerator::readExtensions(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "comment",{} } }, {}); - std::vector children = getChildElements(element); - checkElements(children, { "extension" }); - - for (auto child : children) - { - readExtensionsExtension(child); - } -} - -void VulkanHppGenerator::readExtensionsExtension(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), - { - { "name",{} }, - { "number",{} }, - { "supported",{ "disabled", "vulkan" } } - }, - { - { "author",{} }, - { "comment", {} }, - { "contact",{} }, - { "deprecatedby", {} }, - { "obsoletedby", {} }, - { "platform",{} }, - { "promotedto", {} }, - { "protect",{} }, - { "requires",{} }, - { "requiresCore",{} }, - { "type",{ "device", "instance" } } - }); - std::vector children = getChildElements(element); - checkElements(children, { "require" }); - - if (attributes.find("supported")->second == "disabled") - { - // kick out all the disabled stuff we've read before !! - for (tinyxml2::XMLElement const* child = element->FirstChildElement(); child; child = child->NextSiblingElement()) - { - assert(strcmp(child->Value(), "require") == 0); - readDisabledExtensionRequire(child); - } - } - else - { - std::string name = attributes.find("name")->second; - std::string tag = extractTag(name); - assert(m_tags.find(tag) != m_tags.end()); - - auto protectAttribute = attributes.find("protect"); - auto platformAttribute = attributes.find("platform"); - std::string protect; - if (protectAttribute != attributes.end()) - { - protect = protectAttribute->second; - } - else if (platformAttribute != attributes.end()) - { - auto authorAttribute = attributes.find("author"); - assert(authorAttribute != attributes.end()); - protect = "VK_USE_PLATFORM_" + toUpperCase(platformAttribute->second) + "_" + authorAttribute->second; - } - -#if !defined(NDEBUG) - assert(m_extensions.find(name) == m_extensions.end()); - ExtensionData & extension = m_extensions.insert(std::make_pair(name, ExtensionData())).first->second; - extension.protect = protect; - auto requiresAttribute = attributes.find("requires"); - if (requiresAttribute != attributes.end()) - { - extension.requires = tokenize(requiresAttribute->second, ','); - } -#endif - - for (auto child : children) - { - readExtensionRequire(child, protect, tag); - } - } -} - -void VulkanHppGenerator::readExtensionType(tinyxml2::XMLElement const* element, std::string const& protect) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, {}); - checkElements(getChildElements(element), {}); - - // add the protect-string to the appropriate type: enum, flag, handle, scalar, or struct - if (!protect.empty()) - { - std::string name = strip(attributes.find("name")->second, "Vk"); - std::map::iterator bitmasksIt = m_bitmasks.find(name); - if (bitmasksIt != m_bitmasks.end()) - { - bitmasksIt->second.protect = protect; - - // if the enum of this flags is auto-generated, protect it as well - std::string enumName = generateEnumNameForFlags(name); - std::map::iterator enumsIt = m_enums.find(enumName); - assert(enumsIt != m_enums.end()); - if (enumsIt->second.values.empty()) - { - enumsIt->second.protect = protect; - } - } - else - { - std::map::iterator eit = m_enums.find(name); - if (eit != m_enums.end()) - { - eit->second.protect = protect; - } - else - { - std::map::iterator hait = m_handles.find(name); - if (hait != m_handles.end()) - { - hait->second.protect = protect; - } - else - { - std::map::iterator scit = m_scalars.find(name); - if (scit != m_scalars.end()) - { - scit->second.protect = protect; - } - else - { - std::map::iterator stit = m_structs.find(name); - if (stit != m_structs.end()) - { - stit->second.protect = protect; - } - else - { - assert(m_defines.find(name) != m_defines.end()); - } - } - } - } - } - } -} - -void VulkanHppGenerator::readFeature(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "api",{ "vulkan" } },{ "comment",{} },{ "name",{} },{ "number",{} } }, {}); - std::vector children = getChildElements(element); - checkElements(children, { "require" }); - - for (auto child : children) - { - readFeatureRequire(child); - } -} - -void VulkanHppGenerator::readFeatureRequire(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), {}, { { "comment",{} } }); - std::vector children = getChildElements(element); - checkElements(children, { "command", "comment", "enum", "type" }); - - for (auto child : children) - { - std::string value = child->Value(); - if (value == "enum") - { - readFeatureRequireEnum(child); - } -#if !defined(NDEBUG) - else - { - assert((value == "command") || (value == "comment") || (value == "type")); - skipFeatureRequire(child); - } -#endif - } -} - -void VulkanHppGenerator::readFeatureRequireEnum(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), - { - { "name",{} } - }, - { - { "bitpos",{} }, - { "comment",{} }, - { "dir", { "-" } }, - { "extends",{} }, - { "extnumber", {} }, - { "offset", {} }, - { "value",{} } - }); - checkElements(getChildElements(element), {}); - - auto extendsAttribute = attributes.find("extends"); - if (extendsAttribute != attributes.end()) - { - assert(strncmp(extendsAttribute->second.c_str(), "Vk", 2) == 0); - std::string extends = strip(extendsAttribute->second, "Vk"); - auto enumIt = m_enums.find(extends); - assert(enumIt != m_enums.end()); - enumIt->second.addEnumValue(attributes.find("name")->second, "", m_nameMap); - } -} - -void VulkanHppGenerator::readTags(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), { { "comment",{} } }, {}); - std::vector children = getChildElements(element); - checkElements(children, { "tag" }); - - for (auto child : children) - { - std::string value = child->Value(); - assert(value == "tag"); - readTag(child); - } -} - -void VulkanHppGenerator::readTag(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "author",{} },{ "contact",{} },{ "name",{} } }, {}); - checkElements(getChildElements(element), {}); - - for (auto const& attribute : attributes) - { - std::string name = attribute.first; - if (name == "name") - { - std::string value = attribute.second; - m_tags.insert(value); - } - else - { - assert((name == "author") || (name == "contact")); - } - } -} - -void VulkanHppGenerator::readType(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - - auto categoryIt = attributes.find("category"); - if (categoryIt != attributes.end()) - { - if (categoryIt->second == "basetype") - { - readTypeBasetype(element, attributes); - } - else if (categoryIt->second == "bitmask") - { - readTypeBitmask(element, attributes); - } - else if (categoryIt->second == "define") - { - readTypeDefine(element, attributes); - } - else if (categoryIt->second == "funcpointer") - { - readTypeFuncpointer(element, attributes); - } - else if (categoryIt->second == "handle") - { - readTypeHandle(element, attributes); - } - else if (categoryIt->second == "struct") - { - readTypeStruct(element, false, attributes); - } - else if (categoryIt->second == "union") - { - readTypeStruct(element, true, attributes); - } -#if !defined(NDEBUG) - else if (categoryIt->second == "enum") - { - skipTypeEnum(element, attributes); - } - else if (categoryIt->second == "include") - { - skipTypeInclude(element); - } - else -#else - else if ((categoryIt->second != "enum") && (categoryIt->second != "include")) -#endif - { - std::stringstream ss; - ss << element->GetLineNum(); - std::string lineNumber = ss.str(); - - throw std::runtime_error("Spec error on line " + lineNumber + ": unknown category <" + categoryIt->second + ">"); - } - } - else - { - assert(attributes.find("name") != attributes.end()); - readTypeName(element, attributes); - } -} - -void VulkanHppGenerator::readTypeBasetype(tinyxml2::XMLElement const* element, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), { { "category",{ "basetype" } } }, {}); - std::vector children = getChildElements(element); - checkOrderedElements(children, { "type", "name" }); - checkEmptyElement(children[0]); - checkEmptyElement(children[1]); - - std::string type = children[0]->GetText(); - assert((type == "uint32_t") || (type == "uint64_t")); - - std::string name = strip(children[1]->GetText(), "Vk"); - - // skip "Flags", - if (name != "Flags") - { - m_dependencies.push_back(DependencyData(DependencyData::Category::SCALAR, name)); - m_dependencies.back().dependencies.insert(type); - } - else - { - assert(type == "uint32_t"); - } -} - -void VulkanHppGenerator::readTypeBitmask(tinyxml2::XMLElement const* element, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), { { "category", { "bitmask" } } }, { { "alias", {} }, { "name", {}}, { "requires", {} } }); - std::vector children = getChildElements(element); - - auto aliasIt = attributes.find("alias"); - if (aliasIt != attributes.end()) - { - checkAttributes(attributes, element->GetLineNum(), { { "alias", {} }, { "category", {"bitmask"} }, { "name", {} } }, {}); // re-check on alias type! - checkElements(children, {}); - - std::string alias = strip(aliasIt->second, "Vk"); - checkAlias(m_bitmasks, alias, element->GetLineNum()); - - std::string name = strip(attributes.find("name")->second, "Vk"); - - auto bitmasksIt = m_bitmasks.find(alias); - assert((bitmasksIt != m_bitmasks.end()) && bitmasksIt->second.alias.empty()); - bitmasksIt->second.alias = name; - } - else - { - checkOrderedElements(children, { "type", "name" }); - checkEmptyElement(children[0]); - checkEmptyElement(children[1]); - - assert(strcmp(children[0]->GetText(), "VkFlags") == 0); - - std::string name = strip(children[1]->GetText(), "Vk"); - - std::string requires; - auto requiresIt = attributes.find("requires"); - if (requiresIt != attributes.end()) - { - requires = strip(requiresIt->second, "Vk"); - } - else - { - // Generate FlagBits name, add a DependencyData for that name, and add it to the list of enums and vulkan types - requires = generateEnumNameForFlags(name); - m_dependencies.push_back(DependencyData(DependencyData::Category::ENUM, requires)); - m_enums.insert(std::make_pair(requires, EnumData(requires, true))); - m_vkTypes.insert(requires); - } - - // add a DependencyData for the bitmask name, with the required type as its first dependency - m_dependencies.push_back(DependencyData(DependencyData::Category::BITMASK, name)); - m_dependencies.back().dependencies.insert(requires); - - m_bitmasks.insert(std::make_pair(name, BitmaskData())); - - assert(m_vkTypes.find(name) == m_vkTypes.end()); - m_vkTypes.insert(name); - } -} - -void VulkanHppGenerator::readTypeDefine(tinyxml2::XMLElement const* element, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), { { "category",{ "define" } } }, { { "name",{} } }); - - auto nameIt = attributes.find("name"); - if (nameIt != attributes.end()) - { - assert(!element->FirstChildElement()); - assert(nameIt->second == "VK_DEFINE_NON_DISPATCHABLE_HANDLE"); - - // filter out the check for the different types of VK_DEFINE_NON_DISPATCHABLE_HANDLE - std::string text = element->LastChild()->ToText()->Value(); - size_t start = text.find("#if defined(__LP64__)"); - size_t end = text.find_first_of("\r\n", start + 1); - m_typesafeCheck = text.substr(start, end - start); - } - else if (element->GetText() && (trim(element->GetText()) == "struct")) - { - tinyxml2::XMLElement const* child = element->FirstChildElement(); - assert(child && (strcmp(child->Value(), "name") == 0) && child->GetText()); - m_defines.insert(child->GetText()); - m_dependencies.push_back(DependencyData(DependencyData::Category::REQUIRED, child->GetText())); - } - else - { - tinyxml2::XMLElement const* child = element->FirstChildElement(); - assert(child && !child->FirstAttribute() && (strcmp(child->Value(), "name") == 0) && child->GetText()); - std::string text = trim(child->GetText()); - if (text == "VK_HEADER_VERSION") - { - m_version = element->LastChild()->ToText()->Value(); - } - // ignore all the other defines - assert(!child->NextSiblingElement() || (child->NextSiblingElement() && !child->NextSiblingElement()->FirstAttribute() && (strcmp(child->NextSiblingElement()->Value(), "type") == 0) && !child->NextSiblingElement()->NextSiblingElement())); - } -} - -void VulkanHppGenerator::readTypeFuncpointer(tinyxml2::XMLElement const* element, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), { { "category",{ "funcpointer" } } }, { { "requires",{} } }); - std::vector children = getChildElements(element); - checkElements(children, { "name", "type" }); - assert(!children.empty()); - checkEmptyElement(children[0]); - - assert((strcmp(children[0]->Value(), "name") == 0) && children[0]->GetText()); - m_dependencies.push_back(DependencyData(DependencyData::Category::FUNC_POINTER, children[0]->GetText())); - -#if !defined(NDEBUG) - for (size_t i = 1; i < children.size(); i++) - { - checkEmptyElement(children[i]); - } -#endif -} - -void VulkanHppGenerator::readTypeHandle(tinyxml2::XMLElement const* element, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), { { "category",{ "handle" } } }, { { "alias",{} }, { "name",{} }, { "parent",{} } }); - std::vector children = getChildElements(element); - - auto aliasIt = attributes.find("alias"); - if (aliasIt != attributes.end()) - { - checkAttributes(attributes, element->GetLineNum(), { { "alias",{} },{ "category",{ "handle" } },{ "name",{} } }, {}); // re-check on alias type! - checkElements(children, {}); - - std::string alias = strip(aliasIt->second, "Vk"); - checkAlias(m_handles, alias, element->GetLineNum()); - - std::string name = strip(attributes.find("name")->second, "Vk"); - - auto handlesIt = m_handles.find(alias); - assert((handlesIt != m_handles.end()) && handlesIt->second.alias.empty()); - handlesIt->second.alias = name; - } - else - { - checkOrderedElements(children, { "type", "name" }); - checkEmptyElement(children[0]); - checkEmptyElement(children[1]); - -#if !defined(NDEBUG) - std::string type = children[0]->GetText(); - assert((type.find("VK_DEFINE_HANDLE") == 0) || (type.find("VK_DEFINE_NON_DISPATCHABLE_HANDLE") == 0)); -#endif - - std::string name = strip(children[1]->GetText(), "Vk"); - - m_dependencies.push_back(DependencyData(DependencyData::Category::HANDLE, name)); - - assert(m_vkTypes.find(name) == m_vkTypes.end()); - m_vkTypes.insert(name); - assert(m_handles.find(name) == m_handles.end()); - m_handles.insert(std::make_pair(name, HandleData())); - } -} - -void VulkanHppGenerator::readTypeName(tinyxml2::XMLElement const* element, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { { "requires",{} } }); - checkElements(getChildElements(element), {}); - - auto nameIt = attributes.find("name"); - assert(nameIt != attributes.end()); - m_dependencies.push_back(DependencyData(DependencyData::Category::REQUIRED, nameIt->second)); -} - -void VulkanHppGenerator::readTypes(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), { { "comment",{} } }, {}); - std::vector children = getChildElements(element); - checkElements(children, { "comment", "type" }); - - for (auto child : children) - { - std::string value = child->Value(); - if (value == "type") - { - readType(child); - } -#if !defined(NDEBUG) - else - { - assert(value == "comment"); - checkEmptyElement(child); - } -#endif - } -} - -void VulkanHppGenerator::readTypeStruct(tinyxml2::XMLElement const* element, bool isUnion, std::map const& attributes) -{ - checkAttributes(attributes, element->GetLineNum(), - { - { "category",{ isUnion ? "union" : "struct" } }, - { "name",{} } - }, - { - { "alias", {} }, - { "comment",{} }, - { "returnedonly",{ "true" } }, - { "structextends",{} } - }); - std::vector children = getChildElements(element); - checkElements(children, { "comment", "member" }); - - auto aliasIt = attributes.find("alias"); - if (aliasIt != attributes.end()) - { - checkAttributes(attributes, element->GetLineNum(), { { "alias", {}}, {"category", {"struct"}}, { "name", {}} }, {}); // re-check on alias type! - - std::string alias = strip(aliasIt->second, "Vk"); - checkAlias(m_structs, alias, element->GetLineNum()); - - std::string name = strip(attributes.find("name")->second, "Vk"); - - auto structsIt = m_structs.find(alias); - assert((structsIt != m_structs.end()) && structsIt->second.alias.empty()); - structsIt->second.alias = name; - } - else - { - std::string name = strip(attributes.find("name")->second, "Vk"); - - m_dependencies.push_back(DependencyData(isUnion ? DependencyData::Category::UNION : DependencyData::Category::STRUCT, name)); - - assert(m_structs.find(name) == m_structs.end()); - std::map::iterator it = m_structs.insert(std::make_pair(name, StructData())).first; - it->second.returnedOnly = (attributes.find("returnedonly") != attributes.end()); - it->second.isUnion = isUnion; - - auto attributesIt = attributes.find("structextends"); - if (attributesIt != attributes.end()) - { - std::vector structExtends = tokenize(attributesIt->second, ','); - for (auto const& s : structExtends) - { - assert(s.substr(0, 2) == "Vk"); - std::string strippedName = s.substr(2); - it->second.structExtends.push_back(strippedName); - m_extendedStructs.insert(strippedName); - } - assert(!it->second.structExtends.empty()); - } - - for (auto child : children) - { - assert(child->Value()); - std::string value = child->Value(); - if (value == "member") - { - readTypeStructMember(child, it->second); - } -#if !defined(NDEBUG) - else - { - assert(value == "comment"); - checkEmptyElement(child); - } -#endif - } - - assert(m_vkTypes.find(name) == m_vkTypes.end()); - m_vkTypes.insert(name); - - for (auto const& s : m_structs) - { - if (isSubStruct(s, name, it->second)) - { - it->second.subStruct = s.first; - break; // just take the very first candidate as a subStruct, skip any possible others! - } - } - } -} - -void VulkanHppGenerator::readTypeStructMember(tinyxml2::XMLElement const* element, StructData & structData) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), {}, - { - { "altlen",{} }, - { "externsync",{ "true" } }, - { "len",{} }, - { "noautovalidity",{ "true" } }, - { "optional",{ "false", "true" } }, - { "values",{} } - }); - std::vector children = getChildElements(element); - checkElements(children, { "comment", "enum", "name", "type" }); - for (auto child : children) - { - checkEmptyElement(child); - } - - structData.members.push_back(MemberData()); - MemberData & member = structData.members.back(); - - auto valuesAttribute = attributes.find("values"); - if (valuesAttribute != attributes.end()) - { - member.values = valuesAttribute->second; - } - - tinyxml2::XMLNode const* child = element->FirstChild(); - assert(child); - if (child->ToText()) - { - std::string value = trim(child->Value()); - assert((value == "const") || (value == "struct") || value == "const struct"); - member.type = value + " "; - child = child->NextSibling(); - assert(child); - } - - assert(child->ToElement()); - tinyxml2::XMLElement const* typeElement = child->ToElement(); - assert((strcmp(typeElement->Value(), "type") == 0) && typeElement->GetText()); - member.pureType = strip(typeElement->GetText(), "Vk"); - member.type += member.pureType; - - child = typeElement->NextSibling(); - assert(child); - if (child->ToText()) - { - std::string value = trimEnd(child->Value()); - assert((value == "*") || (value == "**") || (value == "* const*")); - member.type += value; - child = child->NextSibling(); - } - - m_dependencies.back().dependencies.insert(member.pureType); - - assert(child->ToElement()); - tinyxml2::XMLElement const* nameElement = child->ToElement(); - assert((strcmp(nameElement->Value(), "name") == 0) && nameElement->GetText()); - member.name = nameElement->GetText(); - - member.arraySize = readArraySize(nameElement, member.name); -} - -void VulkanHppGenerator::registerDeleter(CommandData const& commandData) -{ - if ((commandData.fullName.substr(0, 7) == "destroy") || (commandData.fullName.substr(0, 4) == "free")) - { - std::string key; - size_t valueIndex; - switch (commandData.params.size()) - { - case 2: - case 3: - assert(commandData.params.back().pureType == "AllocationCallbacks"); - key = (commandData.params.size() == 2) ? "" : commandData.params[0].pureType; - valueIndex = commandData.params.size() - 2; - break; - case 4: - key = commandData.params[0].pureType; - valueIndex = 3; - assert(m_deleters.find(commandData.params[valueIndex].pureType) == m_deleters.end()); - m_deleters[commandData.params[valueIndex].pureType].pool = commandData.params[1].pureType; - break; - default: - assert(false); - valueIndex = 0; - } - assert(m_deleterTypes[key].find(commandData.params[valueIndex].pureType) == m_deleterTypes[key].end()); - m_deleterTypes[key].insert(commandData.params[valueIndex].pureType); - m_deleters[commandData.params[valueIndex].pureType].call = commandData.reducedName; - } -} - -void VulkanHppGenerator::setDefault(std::string const& name, std::map & defaultValues, EnumData const& enumData) -{ - defaultValues[name] = name + (enumData.values.empty() ? "()" : ("::" + enumData.values.front().name)); -} - -void VulkanHppGenerator::sortDependencies() -{ - std::set listedTypes = { "VkFlags" }; - std::list sortedDependencies; - - while (!m_dependencies.empty()) - { - bool found = false; - for (std::list::iterator it = m_dependencies.begin(); it != m_dependencies.end(); ++it) - { - if (std::find_if(it->dependencies.begin(), it->dependencies.end(), [&listedTypes](std::string const& d) { return listedTypes.find(d) == listedTypes.end(); }) == it->dependencies.end()) - { - sortedDependencies.push_back(*it); - listedTypes.insert(it->name); - m_dependencies.erase(it); - found = true; - break; - } - } - if (!found) - { - // resolve direct circular dependencies - for (std::list::iterator it = m_dependencies.begin(); !found && it != m_dependencies.end(); ++it) - { - for (std::set::const_iterator dit = it->dependencies.begin(); dit != it->dependencies.end(); ++dit) - { - std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&dit](DependencyData const& dd) { return(dd.name == *dit); }); - if (depIt != m_dependencies.end()) - { - if (depIt->dependencies.find(it->name) != depIt->dependencies.end()) - { - // we only have just one case, for now! - assert((it->category == DependencyData::Category::HANDLE) && (depIt->category == DependencyData::Category::STRUCT) - || (it->category == DependencyData::Category::STRUCT) && (depIt->category == DependencyData::Category::STRUCT)); - it->forwardDependencies.insert(*dit); - it->dependencies.erase(*dit); - found = true; - break; - } - } -#if !defined(NDEBUG) - else - { - assert(std::find_if(sortedDependencies.begin(), sortedDependencies.end(), [&dit](DependencyData const& dd) { return(dd.name == *dit); }) != sortedDependencies.end()); - } -#endif - } - } - } - assert(found); - } - - m_dependencies.swap(sortedDependencies); -} - -void VulkanHppGenerator::writeArguments(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular, size_t from, size_t to) -{ - assert(from <= to); - - // get the parameter indices of the counter for vector parameters - std::map countIndices; - for (std::map::const_iterator it = commandData.vectorParams.begin(); it != commandData.vectorParams.end(); ++it) - { - countIndices.insert(std::make_pair(it->second, it->first)); - } - - bool encounteredArgument = false; - for (size_t i = from; i < to; i++) - { - if (encounteredArgument) - { - os << ", "; - } - - std::map::const_iterator it = countIndices.find(i); - if (it != countIndices.end()) - { - writeCallCountParameter(os, commandData, singular, it); - } - else if ((it = commandData.vectorParams.find(i)) != commandData.vectorParams.end()) - { - writeCallVectorParameter(os, commandData, firstCall, singular, it); - } - else if (m_vkTypes.find(commandData.params[i].pureType) != m_vkTypes.end()) - { - writeCallVulkanTypeParameter(os, commandData.params[i]); - } - else - { - writeCallPlainTypeParameter(os, commandData.params[i]); - } - encounteredArgument = true; - } -} - -void VulkanHppGenerator::writeBitmaskToString(std::ostream & os, std::string const& bitmaskName, EnumData const &enumData) -{ - // the helper functions to make strings out of flag values - enterProtect(os, enumData.protect); - os << " VULKAN_HPP_INLINE std::string to_string(" << bitmaskName << (enumData.values.empty() ? ")" : " value)") << std::endl - << " {" << std::endl; - if (enumData.values.empty()) - { - // no flags values in this enum -> return "{}" - os << " return \"{}\";" << std::endl; - } - else - { - os << " if (!value) return \"{}\";" << std::endl - << " std::string result;" << std::endl; - - // 'or' together all the bits in the value - for (auto valuesIt = enumData.values.begin(); valuesIt != enumData.values.end(); ++valuesIt) - { - os << " if (value & " << enumData.name << "::" << valuesIt->name << ") result += \"" << valuesIt->name.substr(1) << " | \";" << std::endl; - } - // cut off the last three characters from the result (being " | ") - os << " return \"{\" + result.substr(0, result.size() - 3) + \"}\";" << std::endl; - } - os << " }" << std::endl; - leaveProtect(os, enumData.protect); - os << std::endl; -} - -void VulkanHppGenerator::writeCall(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular) -{ - // the original function call - os << "d.vk" << startUpperCase(commandData.fullName) << "( "; - - if (!commandData.className.empty()) - { - // if it's member of a class -> add the first parameter with "m_" as prefix - os << "m_" << commandData.params[0].name; - if (1 < commandData.params.size()) - { - os << ", "; - } - } - - writeArguments(os, commandData, firstCall, singular, commandData.className.empty() ? 0 : 1, commandData.params.size()); - os << " )"; -} - -void VulkanHppGenerator::writeCallCountParameter(std::ostream & os, CommandData const& commandData, bool singular, std::map::const_iterator it) -{ - // this parameter is a count parameter for a vector parameter - if ((commandData.returnParam == it->second) && commandData.twoStep) - { - // the corresponding vector parameter is the return parameter and it's a two-step algorithm - // -> use the pointer to a local variable named like the counter parameter without leading 'p' - os << "&" << startLowerCase(strip(commandData.params[it->first].name, "p")); - } - else - { - // the corresponding vector parameter is not the return parameter, or it's not a two-step algorithm - if (singular) - { - // for the singular version, the count is just 1. - os << "1 "; - } - else - { - // for the non-singular version, the count is the size of the vector parameter - // -> use the vector parameter name without leading 'p' to get the size (in number of elements, not in bytes) - os << startLowerCase(strip(commandData.params[it->second].name, "p")) << ".size() "; - } - if (commandData.templateParam == it->second) - { - // if the vector parameter is templatized -> multiply by the size of that type to get the size in bytes - os << "* sizeof( T ) "; - } - } -} - -void VulkanHppGenerator::writeCallPlainTypeParameter(std::ostream & os, ParamData const& paramData) -{ - // this parameter is just a plain type - if (paramData.type.back() == '*') - { - // it's a pointer - std::string parameterName = startLowerCase(strip(paramData.name, "p")); - if (paramData.type.find("const") != std::string::npos) - { - // it's a const pointer - if (paramData.pureType == "char") - { - // it's a const pointer to char -> it's a string -> get the data via c_str() - os << parameterName; - if (paramData.optional) - { - // it's optional -> might use nullptr - os << " ? " << parameterName << "->c_str() : nullptr"; - } - else - { - os << ".c_str()"; - } - } - else - { - // it's const pointer to something else -> just use the name - assert(!paramData.optional); - os << paramData.name; - } - } - else - { - // it's a non-const pointer, and char is the only type that occurs -> use the address of the parameter - assert(paramData.type.find("char") == std::string::npos); - os << "&" << parameterName; - } - } - else - { - // it's a plain parameter -> just use its name - os << paramData.name; - } -} - -void VulkanHppGenerator::writeCallVectorParameter(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular, std::map::const_iterator it) -{ - // this parameter is a vector parameter - assert(commandData.params[it->first].type.back() == '*'); - if ((commandData.returnParam == it->first) && commandData.twoStep && firstCall) - { - // this parameter is the return parameter, and it's the first call of a two-step algorithm -> just just nullptr - os << "nullptr"; - } - else - { - std::string parameterName = startLowerCase(strip(commandData.params[it->first].name, "p")); - std::set::const_iterator vkit = m_vkTypes.find(commandData.params[it->first].pureType); - if ((vkit != m_vkTypes.end()) || (it->first == commandData.templateParam)) - { - // CHECK for !commandData.params[it->first].optional - - // this parameter is a vulkan type or a templated type -> need to reinterpret cast - writeReinterpretCast(os, commandData.params[it->first].type.find("const") == 0, vkit != m_vkTypes.end(), commandData.params[it->first].pureType, commandData.params[it->first].type.rfind("* const") != std::string::npos); - os << "( "; - if (singular) - { - // in singular case, strip the plural-S from the name, and use the pointer to that thing - os << "&" << stripPluralS(parameterName); - } - else - { - // in plural case, get the pointer to the data - os << parameterName << ".data()"; - } - os << " )"; - } - else if (commandData.params[it->first].pureType == "char") - { - // the parameter is a vector to char -> it might be optional - // besides that, the parameter now is a std::string -> get the pointer via c_str() - os << parameterName; - if (commandData.params[it->first].optional) - { - os << " ? " << parameterName << "->c_str() : nullptr"; - } - else - { - os << ".c_str()"; - } - } - else - { - // this parameter is just a vetor -> get the pointer to its data - os << parameterName << ".data()"; - } - } -} - -void VulkanHppGenerator::writeCallVulkanTypeParameter(std::ostream & os, ParamData const& paramData) -{ - // this parameter is a vulkan type - if (paramData.type.back() == '*') - { - // it's a pointer -> needs a reinterpret cast to the vulkan type - std::string parameterName = startLowerCase(strip(paramData.name, "p")); - writeReinterpretCast(os, paramData.type.find("const") != std::string::npos, true, paramData.pureType, false); - os << "( "; - if (paramData.optional) - { - // for an optional parameter, we need also a static_cast from optional type to const-pointer to pure type - os << "static_cast( " << parameterName << " )"; - } - else - { - // other parameters can just use the pointer - os << "&" << parameterName; - } - os << " )"; - } - else - { - // a non-pointer parameter needs a static_cast from vk::-type to vulkan type - os << "static_cast( " << paramData.name << " )"; - } -} - -void VulkanHppGenerator::writeEnumsToString(std::ostream & os, EnumData const& enumData) -{ - // the helper functions to make strings out of enum values - enterProtect(os, enumData.protect); - os << " VULKAN_HPP_INLINE std::string to_string(" << enumData.name << (enumData.values.empty() ? ")" : " value)") << std::endl - << " {" << std::endl; - if (enumData.values.empty()) - { - // no enum values in this enum -> return "(void)" - os << " return \"(void)\";" << std::endl; - } - else - { - // otherwise switch over the value and return the a stringized version of that value (without leading 'e') - os << " switch (value)" << std::endl - << " {" << std::endl; - for (auto const& value : enumData.values) - { - os << " case " << enumData.name << "::" << value.name << ": return \"" << value.name.substr(1) << "\";" << std::endl; - } - os << " default: return \"invalid\";" << std::endl - << " }" << std::endl; - } - os << " }" << std::endl; - leaveProtect(os, enumData.protect); - os << std::endl; -} - -// Intended only for `enum class Result`! -void VulkanHppGenerator::writeExceptionsForEnum(std::ostream & os, EnumData const& enumData) -{ - std::string templateString = - R"( class ${className} : public SystemError - { - public: - ${className}( std::string const& message ) - : SystemError( make_error_code( ${enumName}::${enumMemberName} ), message ) {} - ${className}( char const * message ) - : SystemError( make_error_code( ${enumName}::${enumMemberName} ), message ) {} - }; -)"; - - enterProtect(os, enumData.protect); - for (size_t i = 0; i < enumData.values.size(); i++) - { - if (!isErrorEnum(enumData.values[i].name)) - { - continue; - } - os << replaceWithMap(templateString, - { { "className", stripErrorEnumPrefix(enumData.values[i].name) + "Error" }, - { "enumName", enumData.name }, - { "enumMemberName", enumData.values[i].name } - }); - } - leaveProtect(os, enumData.protect); - os << std::endl; -} - -void VulkanHppGenerator::writeFunction(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool definition, bool enhanced, bool singular, bool unique, bool isStructureChain) -{ - writeFunctionHeaderTemplate(os, indentation, commandData, enhanced, unique, !definition, isStructureChain); - - os << indentation << (definition ? "VULKAN_HPP_INLINE " : ""); - writeFunctionHeaderReturnType(os, commandData, enhanced, singular, unique, isStructureChain); - if (definition && !commandData.className.empty()) - { - os << commandData.className << "::"; - } - writeFunctionHeaderName(os, commandData.reducedName, singular, unique); - writeFunctionHeaderArguments(os, commandData, enhanced, singular, !definition); - os << (definition ? "" : ";") << std::endl; - - if (definition) - { - // write the function body - os << indentation << "{" << std::endl; - if (enhanced) - { - writeFunctionBodyEnhanced(os, indentation, commandData, singular, unique, isStructureChain); - } - else - { - writeFunctionBodyStandard(os, indentation, commandData); - } - os << indentation << "}" << std::endl; - } -} - -void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool singular, bool unique, bool isStructureChain) -{ - if (unique && !singular && (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end())) // returns a vector of UniqueStuff - { - std::string const stringTemplate = -R"(${i} static_assert( sizeof( ${type} ) <= sizeof( Unique${type} ), "${type} is greater than Unique${type}!" ); -${i} std::vector ${typeVariable}s; -${i} ${typeVariable}s.reserve( ${vectorSize} ); -${i} ${type}* buffer = reinterpret_cast<${type}*>( reinterpret_cast( ${typeVariable}s.data() ) + ${vectorSize} * ( sizeof( Unique${type} ) - sizeof( ${type} ) ) ); -${i} Result result = static_cast(d.vk${command}( m_device, ${arguments}, reinterpret_cast( buffer ) ) ); - -${i} ${Deleter}<${DeleterTemplate},Dispatch> deleter( *this, ${deleterArg}, d ); -${i} for ( size_t i=0 ; i<${vectorSize} ; i++ ) -${i} { -${i} ${typeVariable}s.push_back( Unique${type}( buffer[i], deleter ) ); -${i} } - -${i} return createResultValue( result, ${typeVariable}s, VULKAN_HPP_NAMESPACE_STRING "::${class}::${function}Unique" ); -)"; - - std::string type = (commandData.returnParam != ~0) ? commandData.params[commandData.returnParam].pureType : ""; - std::string typeVariable = startLowerCase(type); - std::ostringstream arguments; - writeArguments(arguments, commandData, true, singular, 1, commandData.params.size() - 1); - - std::map::const_iterator ddit = m_deleters.find(type); - assert(ddit != m_deleters.end()); - - bool isCreateFunction = (commandData.fullName.substr(0, 6) == "create"); - os << replaceWithMap(stringTemplate, std::map - { - { "i", indentation }, - { "type", type }, - { "typeVariable", typeVariable }, - { "vectorSize", isCreateFunction ? "createInfos.size()" : "allocateInfo." + typeVariable + "Count" }, - { "command", startUpperCase(commandData.fullName) }, - { "arguments", arguments.str() }, - { "Deleter", ddit->second.pool.empty() ? "ObjectDestroy" : "PoolFree" }, - { "DeleterTemplate", ddit->second.pool.empty() ? commandData.className : commandData.className + "," + ddit->second.pool }, - { "deleterArg", ddit->second.pool.empty() ? "allocator" : "allocateInfo." + startLowerCase(ddit->second.pool) }, - { "class", commandData.className }, - { "function", commandData.reducedName } - }); - } - else - { - if (1 < commandData.vectorParams.size()) - { - writeFunctionBodyEnhancedMultiVectorSizeCheck(os, indentation, commandData); - } - - std::string returnName; - if (commandData.returnParam != ~0) - { - returnName = writeFunctionBodyEnhancedLocalReturnVariable(os, indentation, commandData, singular, isStructureChain); - } - - if (commandData.twoStep) - { - assert(!singular); - writeFunctionBodyEnhancedLocalCountVariable(os, indentation, commandData); - - // we now might have to check the result, resize the returned vector accordingly, and call the function again - std::map::const_iterator returnit = commandData.vectorParams.find(commandData.returnParam); - assert(returnit != commandData.vectorParams.end() && (returnit->second != ~0)); - std::string sizeName = startLowerCase(strip(commandData.params[returnit->second].name, "p")); - - if (commandData.returnType == "Result") - { - if (1 < commandData.successCodes.size()) - { - writeFunctionBodyEnhancedCallTwoStepIterate(os, indentation, returnName, sizeName, commandData); - } - else - { - writeFunctionBodyEnhancedCallTwoStepChecked(os, indentation, returnName, sizeName, commandData); - } - } - else - { - writeFunctionBodyEnhancedCallTwoStep(os, indentation, returnName, sizeName, commandData); - } - } - else - { - if (commandData.returnType == "Result") - { - writeFunctionBodyEnhancedCallResult(os, indentation, commandData, singular); - } - else - { - writeFunctionBodyEnhancedCall(os, indentation, commandData, singular); - } - } - - if ((commandData.returnType == "Result") || !commandData.successCodes.empty()) - { - writeFunctionBodyEnhancedReturnResultValue(os, indentation, returnName, commandData, singular, unique); - } - else if ((commandData.returnParam != ~0) && (commandData.returnType != commandData.enhancedReturnType)) - { - // for the other returning cases, when the return type is somhow enhanced, just return the local returnVariable - os << indentation << " return " << returnName << ";" << std::endl; - } - } -} - -void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream &os, std::string const& templateString, std::string const& indentation, CommandData const& commandData, bool singular) -{ - os << replaceWithMap(templateString, { - { "call", generateCall(commandData, true, singular) }, - { "i", indentation } - }); -} - -void VulkanHppGenerator::writeFunctionBodyTwoStep(std::ostream & os, std::string const &templateString, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) -{ - std::map replacements = { - { "sizeName", sizeName }, - { "returnName", returnName }, - { "call1", generateCall(commandData, true, false) }, - { "call2", generateCall(commandData, false, false) }, - { "i", indentation } - }; - - os << replaceWithMap(templateString, replacements); -} - -std::string VulkanHppGenerator::writeFunctionBodyEnhancedLocalReturnVariable(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool singular, bool isStructureChain) -{ - std::string returnName = startLowerCase(strip(commandData.params[commandData.returnParam].name, "p")); - - // there is a returned parameter -> we need a local variable to hold that value - if (commandData.returnType != commandData.enhancedReturnType) - { - // the returned parameter is somehow enhanced by us - os << indentation << " "; - if (singular) - { - if (isStructureChain) - { - std::string const &pureType = commandData.params[commandData.returnParam].pureType; - // For StructureChains use the template parameters - os << "StructureChain structureChain;" << std::endl; - returnName = stripPluralS(returnName); - os << indentation << " " << pureType << "& " << returnName << " = structureChain.template get<" << pureType << ">()"; - returnName = "structureChain"; - } - else - { - // in singular case, just use the return parameters pure type for the return variable - returnName = stripPluralS(returnName); - os << commandData.params[commandData.returnParam].pureType << " " << returnName; - } - } - else - { - // in non-singular case, use the enhanced type for the return variable (like vector<...>) - if (isStructureChain) - { - std::string const &returnType = commandData.enhancedReturnType; - // For StructureChains use the template parameters - os << "StructureChain structureChain;" << std::endl; - os << indentation << " " << returnType << "& " << returnName << " = structureChain.template get<" << returnType << ">()"; - returnName = "structureChain"; - } - else - { - os << commandData.enhancedReturnType << " " << returnName; - } - - std::map::const_iterator it = commandData.vectorParams.find(commandData.returnParam); - if (it != commandData.vectorParams.end() && !commandData.twoStep) - { - // if the return parameter is a vector parameter, and not part of a two-step algorithm, initialize its size - std::string size; - if (it->second == ~0) - { - assert(!commandData.params[commandData.returnParam].len.empty()); - // the size of the vector is not given by an other parameter, but by some member of a parameter, described as 'parameter::member' - // -> replace the '::' by '.' and filter out the leading 'p' to access that value - size = startLowerCase(strip(commandData.params[commandData.returnParam].len, "p")); - size_t pos = size.find("::"); - assert(pos != std::string::npos); - size.replace(pos, 2, "."); - } - else - { - // the size of the vector is given by an other parameter - // first check, if that size has become the size of some other vector parameter - // -> look for it and get it's actual size - for (auto const& vectorParam : commandData.vectorParams) - { - if ((vectorParam.first != it->first) && (vectorParam.second == it->second)) - { - size = startLowerCase(strip(commandData.params[vectorParam.first].name, "p")) + ".size()"; - break; - } - } - if (size.empty()) - { - // otherwise, just use that parameter - size = commandData.params[it->second].name; - } - } - assert(!size.empty()); - os << "( " << size << " )"; - } - } - os << ";" << std::endl; - } - else - { - // the return parameter is not enhanced -> the type is supposed to be a Result and there are more than one success codes! - assert((commandData.returnType == "Result") && (1 < commandData.successCodes.size())); - os << indentation << " " << commandData.params[commandData.returnParam].pureType << " " << returnName << ";" << std::endl; - } - - return returnName; -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedCall(std::ostream &os, std::string const& indentation, CommandData const& commandData, bool singular) -{ - std::string const templateString = "${i} return ${call};\n"; - std::string const templateStringVoid = "${i} ${call};\n"; - writeFunctionBodyEnhanced(os, commandData.returnType == "void" ? templateStringVoid : templateString, indentation, commandData, singular); -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedCallResult(std::ostream &os, std::string const& indentation, CommandData const& commandData, bool singular) -{ - std::string const templateString = "${i} Result result = static_cast( ${call} );\n"; - writeFunctionBodyEnhanced(os, templateString, indentation, commandData, singular); -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedCallTwoStep(std::ostream & os, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) -{ - std::string const templateString = - R"(${i} ${call1}; -${i} ${returnName}.resize( ${sizeName} ); -${i} ${call2}; -)"; - writeFunctionBodyTwoStep(os, templateString, indentation, returnName, sizeName, commandData); -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedCallTwoStepIterate(std::ostream & os, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) -{ - std::string const templateString = - R"(${i} Result result; -${i} do -${i} { -${i} result = static_cast( ${call1} ); -${i} if ( ( result == Result::eSuccess ) && ${sizeName} ) -${i} { -${i} ${returnName}.resize( ${sizeName} ); -${i} result = static_cast( ${call2} ); -${i} } -${i} } while ( result == Result::eIncomplete ); -${i} VULKAN_HPP_ASSERT( ${sizeName} <= ${returnName}.size() ); -${i} ${returnName}.resize( ${sizeName} ); -)"; - writeFunctionBodyTwoStep(os, templateString, indentation, returnName, sizeName, commandData); -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedCallTwoStepChecked(std::ostream & os, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) -{ - std::string const templateString = - R"(${i} Result result = static_cast( ${call1} ); -${i} if ( ( result == Result::eSuccess ) && ${sizeName} ) -${i} { -${i} ${returnName}.resize( ${sizeName} ); -${i} result = static_cast( ${call2} ); -${i} } -)"; - writeFunctionBodyTwoStep(os, templateString, indentation, returnName, sizeName, commandData); -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedLocalCountVariable(std::ostream & os, std::string const& indentation, CommandData const& commandData) -{ - // local count variable to hold the size of the vector to fill - assert(commandData.returnParam != ~0); - - std::map::const_iterator returnit = commandData.vectorParams.find(commandData.returnParam); - assert(returnit != commandData.vectorParams.end() && (returnit->second != ~0)); - assert((commandData.returnType == "Result") || (commandData.returnType == "void")); - - // take the pure type of the size parameter; strip the leading 'p' from its name for its local name - os << indentation << " " << commandData.params[returnit->second].pureType << " " << startLowerCase(strip(commandData.params[returnit->second].name, "p")) << ";" << std::endl; -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedMultiVectorSizeCheck(std::ostream & os, std::string const& indentation, CommandData const& commandData) -{ - std::string const templateString = - R"#(#ifdef VULKAN_HPP_NO_EXCEPTIONS -${i} VULKAN_HPP_ASSERT( ${firstVectorName}.size() == ${secondVectorName}.size() ); -#else -${i} if ( ${firstVectorName}.size() != ${secondVectorName}.size() ) -${i} { -${i} throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${reducedName}: ${firstVectorName}.size() != ${secondVectorName}.size()" ); -${i} } -#endif // VULKAN_HPP_NO_EXCEPTIONS -)#"; - - - // add some error checks if multiple vectors need to have the same size - for (std::map::const_iterator it0 = commandData.vectorParams.begin(); it0 != commandData.vectorParams.end(); ++it0) - { - if (it0->first != commandData.returnParam) - { - for (std::map::const_iterator it1 = std::next(it0); it1 != commandData.vectorParams.end(); ++it1) - { - if ((it1->first != commandData.returnParam) && (it0->second == it1->second)) - { - os << replaceWithMap(templateString, std::map({ - { "firstVectorName", startLowerCase(strip(commandData.params[it0->first].name, "p")) }, - { "secondVectorName", startLowerCase(strip(commandData.params[it1->first].name, "p")) }, - { "className", commandData.className }, - { "reducedName", commandData.reducedName }, - { "i", indentation } - })); - } - } - } - } -} - -void VulkanHppGenerator::writeFunctionBodyEnhancedReturnResultValue(std::ostream & os, std::string const& indentation, std::string const& returnName, CommandData const& commandData, bool singular, bool unique) -{ - std::string type = (commandData.returnParam != ~0) ? commandData.params[commandData.returnParam].pureType : ""; - std::string returnVectorName = (commandData.returnParam != ~0) ? strip(commandData.params[commandData.returnParam].name, "p", "s") : ""; - - if (unique) - { - // the unique version needs a Deleter object for destruction of the newly created stuff - // get the DeleterData corresponding to the returned type - std::map::const_iterator ddit = m_deleters.find(type); - assert(ddit != m_deleters.end() && ddit->second.pool.empty()); - - // special handling for "createDevice", as Device is created from PhysicalDevice, but destroyed on its own - bool noParent = commandData.className.empty() || (commandData.fullName == "createDevice"); - os << std::endl - << indentation << ((commandData.fullName == "allocateMemory") ? " ObjectFree<" : " ObjectDestroy<") << (noParent ? "NoParent" : commandData.className) << ",Dispatch> deleter( " << (noParent ? "" : "*this, ") << "allocator, d );" << std::endl - << indentation << " return createResultValue<" << type << ",Dispatch>( result, "; - } - else - { - os << indentation << " return createResultValue( result, "; - } - - // if the return type is "Result" or there is at least one success code, create the Result/Value construct to return - if (commandData.returnParam != ~0) - { - // if there's a return parameter, list it in the Result/Value constructor - os << returnName << ", "; - } - - // now the function name (with full namespace) as a string - os << "VULKAN_HPP_NAMESPACE_STRING\"::" << (commandData.className.empty() ? "" : commandData.className + "::") << (singular ? stripPluralS(commandData.reducedName) : commandData.reducedName) << (unique ? "Unique" : "") << "\""; - - if (!commandData.twoStep && (1 < commandData.successCodes.size())) - { - // and for the single-step algorithms with more than one success code list them all - os << ", { Result::" << commandData.successCodes[0]; - for (size_t i = 1; i < commandData.successCodes.size(); i++) - { - os << ", Result::" << commandData.successCodes[i]; - } - os << " }"; - } - - if (unique) - { - os << ", deleter"; - } - - os << " );" << std::endl; -} - -void VulkanHppGenerator::writeFunctionBodyStandard(std::ostream & os, std::string const& indentation, CommandData const& commandData) -{ - os << indentation << " "; - bool castReturn = false; - if (commandData.returnType != "void") - { - // there's something to return... - os << "return "; - - castReturn = (m_vkTypes.find(commandData.returnType) != m_vkTypes.end()); - if (castReturn) - { - // the return-type is a vulkan type -> need to cast to vk::-type - os << "static_cast<" << commandData.returnType << ">( "; - } - } - - // call the original function - os << "d.vk" << startUpperCase(commandData.fullName) << "( "; - - if (!commandData.className.empty()) - { - // the command is part of a class -> the first argument is the member variable, starting with "m_" - os << "m_" << commandData.params[0].name; - } - - // list all the arguments - for (size_t i = commandData.className.empty() ? 0 : 1; i < commandData.params.size(); i++) - { - if (0 < i) - { - os << ", "; - } - - if (m_vkTypes.find(commandData.params[i].pureType) != m_vkTypes.end()) - { - // the parameter is a vulkan type - if (commandData.params[i].type.back() == '*') - { - // it's a pointer -> need to reinterpret_cast it - writeReinterpretCast(os, commandData.params[i].type.find("const") == 0, true, commandData.params[i].pureType, commandData.params[i].type.find("* const") != std::string::npos); - } - else - { - // it's a value -> need to static_cast ist - os << "static_cast"; - } - os << "( " << commandData.params[i].name << " )"; - } - else - { - // it's a non-vulkan type -> just use it - os << commandData.params[i].name; - } - } - os << " )"; - - if (castReturn) - { - // if we cast the return -> close the static_cast - os << " )"; - } - os << ";" << std::endl; -} - -void VulkanHppGenerator::writeFunctionHeaderArguments(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool withDefaults) -{ - os << "("; - if (enhanced) - { - writeFunctionHeaderArgumentsEnhanced(os, commandData, singular, withDefaults); - } - else - { - writeFunctionHeaderArgumentsStandard(os, commandData, withDefaults); - } - os << ")"; - if (!commandData.className.empty()) - { - os << " const"; - } -} - -void VulkanHppGenerator::writeFunctionHeaderArgumentsEnhanced(std::ostream & os, CommandData const& commandData, bool singular, bool withDefaults) -{ - // check if there's at least one argument left to put in here - if (commandData.skippedParams.size() + (commandData.className.empty() ? 0 : 1) < commandData.params.size()) - { - // determine the last argument, where we might provide some default for - size_t lastArgument = size_t(~0); - for (size_t i = commandData.params.size() - 1; i < commandData.params.size(); i--) - { - if (commandData.skippedParams.find(i) == commandData.skippedParams.end()) - { - lastArgument = i; - break; - } - } - - os << " "; - bool argEncountered = false; - for (size_t i = commandData.className.empty() ? 0 : 1; i < commandData.params.size(); i++) - { - if (commandData.skippedParams.find(i) == commandData.skippedParams.end()) - { - if (argEncountered) - { - os << ", "; - } - std::string strippedParameterName = startLowerCase(strip(commandData.params[i].name, "p")); - - std::map::const_iterator it = commandData.vectorParams.find(i); - size_t rightStarPos = commandData.params[i].type.rfind('*'); - if (it == commandData.vectorParams.end()) - { - // the argument ist not a vector - if (rightStarPos == std::string::npos) - { - // and its not a pointer -> just use its type and name here - os << commandData.params[i].type << " " << commandData.params[i].name; - if (!commandData.params[i].arraySize.empty()) - { - os << "[" << commandData.params[i].arraySize << "]"; - } - - if (withDefaults && (lastArgument == i)) - { - // check if the very last argument is a flag without any bits -> provide some empty default for it - std::map::const_iterator bitmasksIt = m_bitmasks.find(commandData.params[i].pureType); - if (bitmasksIt != m_bitmasks.end()) - { - // get the enum corresponding to this flag, to check if it's empty - std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&bitmasksIt](DependencyData const& dd) { return(dd.name == bitmasksIt->first); }); - assert((depIt != m_dependencies.end()) && (depIt->dependencies.size() == 1)); - std::map::const_iterator enumIt = m_enums.find(*depIt->dependencies.begin()); - assert(enumIt != m_enums.end()); - if (enumIt->second.values.empty()) - { - // there are no bits in this flag -> provide the default - os << " = " << commandData.params[i].pureType << "()"; - } - } - } - } - else - { - // the argument is not a vector, but a pointer - assert(commandData.params[i].type[rightStarPos] == '*'); - if (commandData.params[i].optional) - { - // for an optional argument, trim the trailing '*' from the type, and the leading 'p' from the name - os << "Optional<" << trimEnd(commandData.params[i].type.substr(0, rightStarPos)) << "> " << strippedParameterName; - if (withDefaults) - { - os << " = nullptr"; - } - } - else if (commandData.params[i].pureType == "void") - { - // for void-pointer, just use type and name - os << commandData.params[i].type << " " << commandData.params[i].name; - } - else if (commandData.params[i].pureType != "char") - { - // for non-char-pointer, change to reference - os << trimEnd(commandData.params[i].type.substr(0, rightStarPos)) << " & " << strippedParameterName; - } - else - { - // for char-pointer, change to const reference to std::string - os << "const std::string & " << strippedParameterName; - } - } - } - else - { - // the argument is a vector - // it's optional, if it's marked as optional and there's no size specified - bool optional = commandData.params[i].optional && (it->second == ~0); - assert((rightStarPos != std::string::npos) && (commandData.params[i].type[rightStarPos] == '*')); - if (commandData.params[i].type.find("char") != std::string::npos) - { - // it's a char-vector -> use a std::string (either optional or a const-reference - if (optional) - { - os << "Optional " << strippedParameterName; - if (withDefaults) - { - os << " = nullptr"; - } - } - else - { - os << "const std::string & " << strippedParameterName; - } - } - else - { - // it's a non-char vector (they are never optional) - assert(!optional); - if (singular) - { - // in singular case, change from pointer to reference - os << trimEnd(commandData.params[i].type.substr(0, rightStarPos)) << " & " << stripPluralS(strippedParameterName); - } - else - { - // otherwise, use our ArrayProxy - bool isConst = (commandData.params[i].type.find("const") != std::string::npos); - os << "ArrayProxy<" << ((commandData.templateParam == i) ? (isConst ? "const T" : "T") : trimEnd(commandData.params[i].type.substr(0, rightStarPos))) << "> " << strippedParameterName; - } - } - } - argEncountered = true; - } - } - - if (argEncountered) - { - os << ", "; - } - } - os << "Dispatch const &d"; - if (withDefaults) - { - os << " = Dispatch()"; - } - - os << " "; -} - -void VulkanHppGenerator::writeFunctionHeaderArgumentsStandard(std::ostream & os, CommandData const& commandData, bool withDefaults) -{ - // for the standard case, just list all the arguments as we've got them - bool argEncountered = false; - - // determine the last argument, where we might provide some default for - size_t lastArgument = commandData.params.size() - 1; - - for (size_t i = commandData.className.empty() ? 0 : 1; i < commandData.params.size(); i++) - { - if (argEncountered) - { - os << ","; - } - - os << " " << commandData.params[i].type << " " << commandData.params[i].name; - if (!commandData.params[i].arraySize.empty()) - { - os << "[" << commandData.params[i].arraySize << "]"; - } - - if (withDefaults && (lastArgument == i)) - { - // check if the very last argument is a flag without any bits -> provide some empty default for it - std::map::const_iterator flagIt = m_bitmasks.find(commandData.params[i].pureType); - if (flagIt != m_bitmasks.end()) - { - // get the enum corresponding to this flag, to check if it's empty - std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&flagIt](DependencyData const& dd) { return(dd.name == flagIt->first); }); - assert((depIt != m_dependencies.end()) && (depIt->dependencies.size() == 1)); - std::map::const_iterator enumIt = m_enums.find(*depIt->dependencies.begin()); - assert(enumIt != m_enums.end()); - if (enumIt->second.values.empty()) - { - // there are no bits in this flag -> provide the default - os << " = " << commandData.params[i].pureType << "()"; - } - } - } - argEncountered = true; - } - if (argEncountered) - { - os << ", "; - } - - os << "Dispatch const &d"; - if (withDefaults) - { - os << " = Dispatch() "; - } -} - -void VulkanHppGenerator::writeFunctionHeaderReturnType(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain) -{ - std::string templateString; - std::string returnType; - if (enhanced) - { - // the enhanced function might return some pretty complex return stuff - if (isStructureChain || (!singular && (commandData.enhancedReturnType.find("Allocator") != std::string::npos))) - { - // for the non-singular case with allocation, we need to prepend with 'typename' to keep compilers happy - templateString = "typename "; - } - if (unique) - { - // the unique version returns something prefixed with 'Unique'; potentially a vector of that stuff - // it's a vector, if it's not the singular version and the return parameter is a vector parameter - bool returnsVector = !singular && (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end()); - - templateString += returnsVector ? "ResultValueType,Allocator>>::type " : "typename ResultValueType>::type "; - returnType = isStructureChain ? "StructureChain" : commandData.params[commandData.returnParam].pureType; - } - else if ((commandData.enhancedReturnType != commandData.returnType) && (commandData.returnType != "void")) - { - // if the enhanced return type differs from the original return type, and it's not void, we return a ResultValueType<...>::type - templateString += "ResultValueType<${returnType}>::type "; - - assert(commandData.returnType == "Result"); - // in singular case, we create the ResultValueType from the pure return type, otherwise from the enhanced return type - if (isStructureChain) - { - returnType = "StructureChain"; - } - else - { - returnType = singular ? commandData.params[commandData.returnParam].pureType : commandData.enhancedReturnType; - } - } - else if ((commandData.returnParam != ~0) && (1 < commandData.successCodes.size())) - { - // if there is a return parameter at all, and there are multiple success codes, we return a ResultValue<...> with the pure return type - assert(commandData.returnType == "Result"); - templateString = "ResultValue<${returnType}> "; - returnType = isStructureChain ? "StructureChain" : commandData.params[commandData.returnParam].pureType; - } - else - { - // and in every other case, we just return the enhanced return type. - templateString = "${returnType} "; - returnType = isStructureChain ? "StructureChain" : commandData.enhancedReturnType; - } - } - else - { - // the non-enhanced function just uses the return type - templateString = "${returnType} "; - returnType = commandData.returnType; - } - os << replaceWithMap(templateString, { { "returnType", returnType } }); -} - -void VulkanHppGenerator::writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool unique, bool withDefault, bool isStructureChain) -{ - std::string dispatch = withDefault ? std::string("typename Dispatch = DispatchLoaderStatic") : std::string("typename Dispatch"); - if (enhanced && isStructureChain) - { - os << indentation << "template " << std::endl; - } - else if (enhanced && (commandData.templateParam != ~0) && ((commandData.templateParam != commandData.returnParam) || (commandData.enhancedReturnType == "Result"))) - { - // if there's a template parameter, not being the return parameter or where the enhanced return type is 'Result' -> templatize on type 'T' - assert(commandData.enhancedReturnType.find("Allocator") == std::string::npos); - os << indentation << "template " << std::endl; - } - else if (enhanced && (commandData.enhancedReturnType.find("Allocator") != std::string::npos)) - { - // otherwise, if there's an Allocator used in the enhanced return type, we templatize on that Allocator - assert((commandData.enhancedReturnType.substr(0, 12) == "std::vector<") && (commandData.enhancedReturnType.find(',') != std::string::npos) && (12 < commandData.enhancedReturnType.find(','))); - os << indentation << "template ' - os << " = std::allocator<" << (unique ? "Unique" : "") << commandData.enhancedReturnType.substr(12, commandData.enhancedReturnType.find(',') - 12) << ">"; - } - os << ", " << dispatch; - os << "> " << std::endl; - } - else - { - os << indentation << "template<" << dispatch << ">" << std::endl; - } -} - -void VulkanHppGenerator::writeResultEnum(std::ostream & os) -{ - std::list::const_iterator it = std::find_if(m_dependencies.begin(), m_dependencies.end(), [](DependencyData const& dp) { return dp.name == "Result"; }); - assert(it != m_dependencies.end()); - writeTypeEnum(os, m_enums.find(it->name)->second); - writeEnumsToString(os, m_enums.find(it->name)->second); - os << "#ifndef VULKAN_HPP_NO_EXCEPTIONS"; - os << exceptionHeader; - os << exceptionClassesHeader; - writeExceptionsForEnum(os, m_enums.find(it->name)->second); - writeThrowExceptions(os, m_enums.find(it->name)->second); - os << "#endif" << std::endl; - m_dependencies.erase(it); -} - -void VulkanHppGenerator::writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map const& defaultValues) -{ - // the constructor with all the elements as arguments, with defaults - std::string ctorOpening = " " + name + "( "; - size_t indentSize = ctorOpening.size(); - os << ctorOpening; - - bool listedArgument = false; - for (size_t i = 0; i < structData.members.size(); i++) - { - listedArgument = writeStructConstructorArgument(os, listedArgument, indentSize, structData.members[i], defaultValues); - } - os << " )" << std::endl; - - // copy over the simple arguments - bool firstArgument = true; - for (size_t i = 0; i < structData.members.size(); i++) - { - // skip members 'pNext' and 'sType' are directly set by initializers - if ((structData.members[i].name != "pNext") && (structData.members[i].name != "sType") && (structData.members[i].arraySize.empty())) - { - // here, we can only handle non-array arguments - std::string templateString = " ${sep} ${member}( ${value} )\n"; - std::string sep = firstArgument ? ":" : ","; - std::string member = structData.members[i].name; - std::string value = structData.members[i].name + "_"; // the elements are initialized by the corresponding argument (with trailing '_', as mentioned above) - - os << replaceWithMap(templateString, { { "sep", sep },{ "member", member },{ "value", value } }); - firstArgument = false; - } - } - - // the body of the constructor, copying over data from argument list into wrapped struct - os << " {" << std::endl; - for (size_t i = 0; i < structData.members.size(); i++) - { - if (!structData.members[i].arraySize.empty()) - { - // here we can handle the arrays, copying over from argument (with trailing '_') to member - // size is arraySize times sizeof type - std::string member = structData.members[i].name; - std::string arraySize = structData.members[i].arraySize; - std::string type = structData.members[i].type; - os << replaceWithMap(" memcpy( &${member}, ${member}_.data(), ${arraySize} * sizeof( ${type} ) );\n", - { { "member", member },{ "arraySize", arraySize },{ "type", type } }); - } - } - os << " }\n\n"; - - if (!structData.subStruct.empty()) - { - auto const& subStruct = m_structs.find(structData.subStruct); - assert(subStruct != m_structs.end()); - - std::string subStructArgumentName = startLowerCase(strip(subStruct->first, "vk")); - ctorOpening = " explicit " + name + "( "; - indentSize = ctorOpening.size(); - - os << ctorOpening << subStruct->first << " const& " << subStructArgumentName; - - for (size_t i = subStruct->second.members.size(); i < structData.members.size(); i++) - { - writeStructConstructorArgument(os, true, indentSize, structData.members[i], defaultValues); - } - os << " )" << std::endl; - - firstArgument = true; - std::string templateString = " ${sep} ${member}( ${value} )\n"; - for (size_t i = 0; i < subStruct->second.members.size(); i++) - { - assert(structData.members[i].arraySize.empty()); - std::string sep = firstArgument ? ":" : ","; - std::string member = structData.members[i].name; - std::string value = subStructArgumentName + "." + subStruct->second.members[i].name; - - os << replaceWithMap(templateString, { { "sep", sep },{ "member", member },{ "value", value } }); - firstArgument = false; - } - for (size_t i = subStruct->second.members.size(); i < structData.members.size(); i++) - { - assert(structData.members[i].arraySize.empty()); - std::string member = structData.members[i].name; - std::string value = structData.members[i].name + "_"; // the elements are initialized by the corresponding argument (with trailing '_', as mentioned above) - - os << replaceWithMap(templateString, { { "sep", "," },{ "member", member },{ "value", value } }); - } - os << " {}" << std::endl << std::endl; - } - - std::string templateString = - R"( ${name}( Vk${name} const & rhs ) - { - memcpy( this, &rhs, sizeof( ${name} ) ); - } - - ${name}& operator=( Vk${name} const & rhs ) - { - memcpy( this, &rhs, sizeof( ${name} ) ); - return *this; - } -)"; - - os << replaceWithMap(templateString, { { "name", name } }); -} - -void VulkanHppGenerator::writeIndentation(std::ostream & os, size_t indentLength) -{ - for(size_t i = 0; i < indentLength; i++) - { - os << " "; - } -} - -bool VulkanHppGenerator::writeStructConstructorArgument(std::ostream & os, bool listedArgument, size_t indentLength, MemberData const& memberData, std::map const& defaultValues) -{ - if (listedArgument) - { - os << ",\n"; - writeIndentation(os, indentLength); - } - - // skip members 'pNext' and 'sType', as they are never explicitly set - if ((memberData.name != "pNext") && (memberData.name != "sType")) - { - // find a default value for the given pure type - std::map::const_iterator defaultIt = defaultValues.find(memberData.pureType); - assert(defaultIt != defaultValues.end()); - - if (memberData.arraySize.empty()) - { - // the arguments name get a trailing '_', to distinguish them from the actual struct members - // pointer arguments get a nullptr as default - os << memberData.type << " " << memberData.name << "_ = " << (memberData.type.back() == '*' ? "nullptr" : defaultIt->second); - } - else - { - // array members are provided as const reference to a std::array - // the arguments name get a trailing '_', to distinguish them from the actual struct members - // list as many default values as there are elements in the array - os << "std::array<" << memberData.type << "," << memberData.arraySize << "> const& " << memberData.name << "_ = { { " << defaultIt->second; - size_t n = atoi(memberData.arraySize.c_str()); - assert(0 < n); - for (size_t j = 1; j < n; j++) - { - os << ", " << defaultIt->second; - } - os << " } }"; - } - listedArgument = true; - } - return listedArgument; -} - -void VulkanHppGenerator::writeStructSetter(std::ostream & os, std::string const& structureName, MemberData const& memberData) -{ - if (memberData.type != "StructureType") // filter out StructureType, which is supposed to be immutable ! - { - // the setters return a reference to the structure - os << " " << structureName << "& set" << startUpperCase(memberData.name) << "( "; - if (memberData.arraySize.empty()) - { - os << memberData.type << " "; - } - else - { - os << "std::array<" << memberData.type << "," << memberData.arraySize << "> "; - } - // add a trailing '_' to the argument to distinguish it from the structure member - os << memberData.name << "_ )" << std::endl - << " {" << std::endl; - // copy over the argument, either by assigning simple data, or by memcpy array data - if (memberData.arraySize.empty()) - { - os << " " << memberData.name << " = " << memberData.name << "_"; - } - else - { - os << " memcpy( &" << memberData.name << ", " << memberData.name << "_.data(), " << memberData.arraySize << " * sizeof( " << memberData.type << " ) )"; - } - os << ";" << std::endl - << " return *this;" << std::endl - << " }" << std::endl - << std::endl; - } -} - -void VulkanHppGenerator::writeStructureChainValidation(std::ostream & os) -{ - // write all template functions for the structure pointer chain validation - for (auto it = m_dependencies.begin(); it != m_dependencies.end(); ++it) - { - switch (it->category) - { - case DependencyData::Category::STRUCT: - writeStructureChainValidation(os, *it); - break; - } - } -} - -void VulkanHppGenerator::writeStructureChainValidation(std::ostream & os, DependencyData const& dependencyData) -{ - std::map::const_iterator it = m_structs.find(dependencyData.name); - assert(it != m_structs.end()); - - if (!it->second.structExtends.empty()) { - enterProtect(os, it->second.protect); - - // write out allowed structure chains - for (auto extendName : it->second.structExtends) - { - std::map::const_iterator itExtend = m_structs.find(extendName); - if (itExtend == m_structs.end()) { - std::stringstream errorString; - errorString << extendName << " does not specify a struct in structextends field."; - - // check if symbol name is an alias to a struct - auto itAlias = std::find_if(m_structs.begin(), m_structs.end(), [&extendName](std::pair const &it) -> bool {return it.second.alias == extendName;}); - if (itAlias != m_structs.end()) - { - errorString << " The symbol is an alias and maps to " << itAlias->first << "."; - } - - errorString << std::endl; - throw std::runtime_error(errorString.str()); - } - enterProtect(os, itExtend->second.protect); - - os << " template <> struct isStructureChainValid<" << extendName << ", " << dependencyData.name << ">{ enum { value = true }; };" << std::endl; - - leaveProtect(os, itExtend->second.protect); - } - leaveProtect(os, it->second.protect); - } -} - -void VulkanHppGenerator::writeThrowExceptions(std::ostream & os, EnumData const& enumData) -{ - enterProtect(os, enumData.protect); - os << - R"( VULKAN_HPP_INLINE void throwResultException( Result result, char const * message ) - { - switch ( result ) - { -)"; - for (size_t i = 0; icategory) - { - case DependencyData::Category::BITMASK: - writeBitmaskToString(os, it->name, m_enums.find(*it->dependencies.begin())->second); - break; - case DependencyData::Category::ENUM: - assert(m_enums.find(it->name) != m_enums.end()); - writeEnumsToString(os, m_enums.find(it->name)->second); - break; - } - } -} - -void VulkanHppGenerator::writeTypeBitmask(std::ostream & os, std::string const& bitmaskName, BitmaskData const& bitmaskData, EnumData const& enumData) -{ - enterProtect(os, bitmaskData.protect); - - // each Flags class is using on the class 'Flags' with the corresponding FlagBits enum as the template parameter - os << " using " << bitmaskName << " = Flags<" << enumData.name << ", Vk" << bitmaskName << ">;" << std::endl; - - std::stringstream allFlags; - for (size_t i = 0; i < enumData.values.size(); i++) - { - if (i != 0) - { - allFlags << " | "; - } - allFlags << "VkFlags(" << enumData.name << "::" << enumData.values[i].name << ")"; - } - - if (!enumData.values.empty()) - { - const std::string templateString = R"( - VULKAN_HPP_INLINE ${bitmaskName} operator|( ${enumName} bit0, ${enumName} bit1 ) - { - return ${bitmaskName}( bit0 ) | bit1; - } - - VULKAN_HPP_INLINE ${bitmaskName} operator~( ${enumName} bits ) - { - return ~( ${bitmaskName}( bits ) ); - } - - template <> struct FlagTraits<${enumName}> - { - enum - { - allFlags = ${allFlags} - }; - }; -)"; - os << replaceWithMap(templateString, { { "bitmaskName", bitmaskName },{ "enumName", enumData.name },{ "allFlags", allFlags.str() } }); - } - - if (!bitmaskData.alias.empty()) - { - os << std::endl - << " using " << bitmaskData.alias << " = " << bitmaskName << ";" << std::endl; - } - - leaveProtect(os, bitmaskData.protect); - os << std::endl; -} - -void VulkanHppGenerator::writeTypeCommand(std::ostream & os, DependencyData const& dependencyData) -{ - assert(m_commands.find(dependencyData.name) != m_commands.end()); - CommandData const& commandData = m_commands.find(dependencyData.name)->second; - if (commandData.className.empty()) - { - if (commandData.fullName == "createInstance") - { - // special handling for createInstance, as we need to explicitly place the forward declarations and the deleter classes here -#if !defined(NDEBUG) - auto deleterTypesIt = m_deleterTypes.find(""); - assert((deleterTypesIt != m_deleterTypes.end()) && (deleterTypesIt->second.size() == 2)); - assert(deleterTypesIt->second.find("Instance") != deleterTypesIt->second.end()); -#endif - - writeUniqueTypes(os, std::make_pair>("", { "Instance" })); - writeTypeCommand(os, " ", commandData, false); - } - else - { - writeTypeCommand(os, " ", commandData, false); - } - writeTypeCommand(os, " ", commandData, true); - os << std::endl; - } -} - -void VulkanHppGenerator::writeTypeCommand(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool definition) -{ - enterProtect(os, commandData.protect); - - bool isStructureChain = m_extendedStructs.find(commandData.enhancedReturnType) != m_extendedStructs.end(); - - // first create the standard version of the function - std::ostringstream standard; - writeFunction(standard, indentation, commandData, definition, false, false, false, false); - - // then the enhanced version, composed by up to five parts - std::ostringstream enhanced; - writeFunction(enhanced, indentation, commandData, definition, true, false, false, false); - - if (isStructureChain) - { - writeFunction(enhanced, indentation, commandData, definition, true, false, false, true); - } - - // then a singular version, if a sized vector would be returned - std::map::const_iterator returnVector = commandData.vectorParams.find(commandData.returnParam); - bool singular = (returnVector != commandData.vectorParams.end()) && - (returnVector->second != ~0) && - (commandData.params[returnVector->first].pureType != "void") && - (commandData.params[returnVector->second].type.back() != '*'); - if (singular) - { - writeFunction(enhanced, indentation, commandData, definition, true, true, false, false); - } - - // special handling for createDevice and createInstance ! - bool specialWriteUnique = (commandData.reducedName == "createDevice") || (commandData.reducedName == "createInstance"); - - // and then the same for the Unique* versions (a Deleter is available for the commandData's class, and the function starts with 'allocate' or 'create') - if (((m_deleters.find(commandData.className) != m_deleters.end()) || specialWriteUnique) && ((commandData.reducedName.substr(0, 8) == "allocate") || (commandData.reducedName.substr(0, 6) == "create"))) - { - enhanced << "#ifndef VULKAN_HPP_NO_SMART_HANDLE" << std::endl; - writeFunction(enhanced, indentation, commandData, definition, true, false, true, false); - - if (singular) - { - writeFunction(enhanced, indentation, commandData, definition, true, true, true, false); - } - enhanced << "#endif /*VULKAN_HPP_NO_SMART_HANDLE*/" << std::endl; - } - - // and write one or both of them - writeStandardOrEnhanced(os, standard.str(), enhanced.str()); - - leaveProtect(os, commandData.protect); - os << std::endl; -} - -void VulkanHppGenerator::writeTypeEnum(std::ostream & os, EnumData const& enumData) -{ - // a named enum per enum, listing all its values by setting them to the original Vulkan names - enterProtect(os, enumData.protect); - os << " enum class " << enumData.name << std::endl - << " {" << std::endl; - for (size_t i = 0; i list them first - if (!dependencyData.forwardDependencies.empty()) - { - os << " // forward declarations" << std::endl; - for (std::set::const_iterator it = dependencyData.forwardDependencies.begin(); it != dependencyData.forwardDependencies.end(); ++it) - { - assert(m_structs.find(*it) != m_structs.end()); - os << " struct " << *it << ";" << std::endl; - } - os << std::endl; - } - - // then write any forward declaration of Deleters used by this handle - std::map>::const_iterator deleterTypesIt = m_deleterTypes.find(dependencyData.name); - if (deleterTypesIt != m_deleterTypes.end()) - { - writeUniqueTypes(os, *deleterTypesIt); - } - else if (dependencyData.name == "PhysicalDevice") - { - // special handling for class Device, as it's created from PhysicalDevice, but destroys itself - writeUniqueTypes(os, std::make_pair>("", { "Device" })); - } - - const std::string memberName = startLowerCase(dependencyData.name); - const std::string templateString = - R"( class ${className} - { - public: - VULKAN_HPP_CONSTEXPR ${className}() - : m_${memberName}(VK_NULL_HANDLE) - {} - - VULKAN_HPP_CONSTEXPR ${className}( std::nullptr_t ) - : m_${memberName}(VK_NULL_HANDLE) - {} - - VULKAN_HPP_TYPESAFE_EXPLICIT ${className}( Vk${className} ${memberName} ) - : m_${memberName}( ${memberName} ) - {} - -#if defined(VULKAN_HPP_TYPESAFE_CONVERSION) - ${className} & operator=(Vk${className} ${memberName}) - { - m_${memberName} = ${memberName}; - return *this; - } -#endif - - ${className} & operator=( std::nullptr_t ) - { - m_${memberName} = VK_NULL_HANDLE; - return *this; - } - - bool operator==( ${className} const & rhs ) const - { - return m_${memberName} == rhs.m_${memberName}; - } - - bool operator!=(${className} const & rhs ) const - { - return m_${memberName} != rhs.m_${memberName}; - } - - bool operator<(${className} const & rhs ) const - { - return m_${memberName} < rhs.m_${memberName}; - } - -${commands} - - VULKAN_HPP_TYPESAFE_EXPLICIT operator Vk${className}() const - { - return m_${memberName}; - } - - explicit operator bool() const - { - return m_${memberName} != VK_NULL_HANDLE; - } - - bool operator!() const - { - return m_${memberName} == VK_NULL_HANDLE; - } - - private: - Vk${className} m_${memberName}; - }; - - static_assert( sizeof( ${className} ) == sizeof( Vk${className} ), "handle and wrapper have different size!" ); - -)"; - - std::ostringstream commands; - // now list all the commands that are mapped to members of this class - for (size_t i = 0; i < handleData.commands.size(); i++) - { - std::map::const_iterator cit = m_commands.find(handleData.commands[i]); - assert((cit != m_commands.end()) && !cit->second.className.empty()); - writeTypeCommand(commands, " ", cit->second, false); - - // special handling for destroy functions which are not aliased. - if (!cit->second.isAlias && (((cit->second.fullName.substr(0, 7) == "destroy") && (cit->second.reducedName != "destroy")) || (cit->second.fullName.substr(0, 4) == "free"))) - { - CommandData shortenedCommand = cit->second; - shortenedCommand.reducedName = (cit->second.fullName.substr(0, 7) == "destroy") ? "destroy" : "free"; - writeTypeCommand(commands, " ", shortenedCommand, false); - } - } - - os << replaceWithMap(templateString, { - { "className", dependencyData.name }, - { "memberName", memberName }, - { "commands", commands.str() } - }); - - // and finally the commands, that are member functions of this handle - for (size_t i = 0; i < handleData.commands.size(); i++) - { - std::string commandName = handleData.commands[i]; - std::map::const_iterator cit = m_commands.find(commandName); - assert((cit != m_commands.end()) && !cit->second.className.empty()); - std::list::const_iterator dep = std::find_if(m_dependencies.begin(), m_dependencies.end(), [commandName](DependencyData const& dd) { return dd.name == commandName; }); - assert(dep != m_dependencies.end() && (dep->name == cit->second.fullName)); - writeTypeCommand(os, " ", cit->second, true); - - // special handling for destroy functions - if (!cit->second.isAlias && (((cit->second.fullName.substr(0, 7) == "destroy") && (cit->second.reducedName != "destroy")) || (cit->second.fullName.substr(0, 4) == "free"))) - { - CommandData shortenedCommand = cit->second; - shortenedCommand.reducedName = (cit->second.fullName.substr(0, 7) == "destroy") ? "destroy" : "free"; - writeTypeCommand(os, " ", shortenedCommand, true); - } - } - - if (!handleData.alias.empty()) - { - os << " using " << handleData.alias << " = " << dependencyData.name << ";" << std::endl - << std::endl; - } - - leaveProtect(os, handleData.protect); -} - -void VulkanHppGenerator::writeTypes(std::ostream & os, std::map const& defaultValues) -{ - assert(m_deleterTypes.find("") != m_deleterTypes.end()); - - for (std::list::const_iterator it = m_dependencies.begin(); it != m_dependencies.end(); ++it) - { - switch (it->category) - { - case DependencyData::Category::BITMASK: - assert(m_bitmasks.find(it->name) != m_bitmasks.end()); - writeTypeBitmask(os, it->name, m_bitmasks.find(it->name)->second, m_enums.find(generateEnumNameForFlags(it->name))->second); - break; - case DependencyData::Category::COMMAND: - writeTypeCommand(os, *it); - break; - case DependencyData::Category::ENUM: - assert(m_enums.find(it->name) != m_enums.end()); - writeTypeEnum(os, m_enums.find(it->name)->second); - break; - case DependencyData::Category::FUNC_POINTER: - case DependencyData::Category::REQUIRED: - // skip FUNC_POINTER and REQUIRED, they just needed to be in the dependencies list to resolve dependencies - break; - case DependencyData::Category::HANDLE: - assert(m_handles.find(it->name) != m_handles.end()); - writeTypeHandle(os, *it, m_handles.find(it->name)->second); - break; - case DependencyData::Category::SCALAR: - writeTypeScalar(os, *it); - break; - case DependencyData::Category::STRUCT: - writeTypeStruct(os, *it, defaultValues); - break; - case DependencyData::Category::UNION: - assert(m_structs.find(it->name) != m_structs.end()); - writeTypeUnion(os, *it, defaultValues); - break; - default: - assert(false); - break; - } - } -} - -void VulkanHppGenerator::writeTypeScalar(std::ostream & os, DependencyData const& dependencyData) -{ - assert(dependencyData.dependencies.size() == 1); - os << " using " << dependencyData.name << " = " << *dependencyData.dependencies.begin() << ";" << std::endl - << std::endl; -} - -void VulkanHppGenerator::writeTypeStruct(std::ostream & os, DependencyData const& dependencyData, std::map const& defaultValues) -{ - std::map::const_iterator it = m_structs.find(dependencyData.name); - assert(it != m_structs.end()); - - enterProtect(os, it->second.protect); - os << " struct " << dependencyData.name << std::endl - << " {" << std::endl; - - // only structs that are not returnedOnly get a constructor! - if (!it->second.returnedOnly) - { - writeStructConstructor(os, dependencyData.name, it->second, defaultValues); - } - - // create the setters - if (!it->second.returnedOnly) - { - for (size_t i = 0; isecond.members.size(); i++) - { - writeStructSetter(os, dependencyData.name, it->second.members[i]); - } - } - - // the cast-operator to the wrapped struct - os << " operator const Vk" << dependencyData.name << "&() const" << std::endl - << " {" << std::endl - << " return *reinterpret_cast(this);" << std::endl - << " }" << std::endl - << std::endl; - - // operator==() and operator!=() - // only structs without a union as a member can have a meaningfull == and != operation; we filter them out - if (!containsUnion(dependencyData.name, m_structs)) - { - // two structs are compared by comparing each of the elements - os << " bool operator==( " << dependencyData.name << " const& rhs ) const" << std::endl - << " {" << std::endl - << " return "; - for (size_t i = 0; i < it->second.members.size(); i++) - { - if (i != 0) - { - os << std::endl << " && "; - } - if (!it->second.members[i].arraySize.empty()) - { - os << "( memcmp( " << it->second.members[i].name << ", rhs." << it->second.members[i].name << ", " << it->second.members[i].arraySize << " * sizeof( " << it->second.members[i].type << " ) ) == 0 )"; - } - else - { - os << "( " << it->second.members[i].name << " == rhs." << it->second.members[i].name << " )"; - } - } - os << ";" << std::endl - << " }" << std::endl - << std::endl - << " bool operator!=( " << dependencyData.name << " const& rhs ) const" << std::endl - << " {" << std::endl - << " return !operator==( rhs );" << std::endl - << " }" << std::endl - << std::endl; - } - - // the member variables - for (size_t i = 0; i < it->second.members.size(); i++) - { - if (it->second.members[i].type == "StructureType") - { - assert((i == 0) && (it->second.members[i].name == "sType")); - if (!it->second.members[i].values.empty()) - { - assert(!it->second.members[i].values.empty()); - auto nameIt = m_nameMap.find(it->second.members[i].values); - assert(nameIt != m_nameMap.end()); - os << " private:" << std::endl - << " StructureType sType = " << nameIt->second << ";" << std::endl - << std::endl - << " public:" << std::endl; - } - else - { - os << " StructureType sType;" << std::endl; - } - } - else - { - os << " " << it->second.members[i].type << " " << it->second.members[i].name; - if (it->second.members[i].name == "pNext") - { - os << " = nullptr"; - } - else if (!it->second.members[i].arraySize.empty()) - { - os << "[" << it->second.members[i].arraySize << "]"; - } - os << ";" << std::endl; - } - } - os << " };" << std::endl - << " static_assert( sizeof( " << dependencyData.name << " ) == sizeof( Vk" << dependencyData.name << " ), \"struct and wrapper have different size!\" );" << std::endl; - - if (!it->second.alias.empty()) - { - os << std::endl - << " using " << it->second.alias << " = " << dependencyData.name << ";" << std::endl; - } - - leaveProtect(os, it->second.protect); - os << std::endl; -} - -void VulkanHppGenerator::writeUniqueTypes(std::ostream &os, std::pair> const& deleterTypes) -{ - os << "#ifndef VULKAN_HPP_NO_SMART_HANDLE" << std::endl; - if (!deleterTypes.first.empty()) - { - os << " class " << deleterTypes.first << ";" << std::endl; - } - os << std::endl; - - for (auto const& dt : deleterTypes.second) - { - auto ddit = m_deleters.find(dt); - assert(ddit != m_deleters.end()); - - std::string deleterType = (deleterTypes.first.empty() ? "NoParent" : deleterTypes.first); - - os << " template class UniqueHandleTraits<" << dt << ",Dispatch> {public: " << "using owner = " << deleterType << "; " << "using deleter = " << (ddit->second.pool.empty() ? "Object" : "Pool") << ((ddit->second.call.substr(0, 4) == "free") ? "Free<" : "Destroy<") << "owner" << (ddit->second.pool.empty() ? "" : ", " + ddit->second.pool) << ",Dispatch>;};\n"; - os << " using Unique" << dt << " = UniqueHandle<" << dt << ",DispatchLoaderStatic>;" << std::endl; - } - os << "#endif /*VULKAN_HPP_NO_SMART_HANDLE*/" << std::endl - << std::endl; -} - -void VulkanHppGenerator::writeTypeUnion(std::ostream & os, DependencyData const& dependencyData, std::map const& defaultValues) -{ - std::map::const_iterator it = m_structs.find(dependencyData.name); - assert(it != m_structs.end()); - - std::ostringstream oss; - os << " union " << dependencyData.name << std::endl - << " {" << std::endl; - - for (size_t i = 0; isecond.members.size(); i++) - { - // one constructor per union element - os << " " << dependencyData.name << "( "; - if (it->second.members[i].arraySize.empty()) - { - os << it->second.members[i].type << " "; - } - else - { - os << "const std::array<" << it->second.members[i].type << "," << it->second.members[i].arraySize << ">& "; - } - os << it->second.members[i].name << "_"; - - // just the very first constructor gets default arguments - if (i == 0) - { - std::map::const_iterator defaultIt = defaultValues.find(it->second.members[i].pureType); - assert(defaultIt != defaultValues.end()); - if (it->second.members[i].arraySize.empty()) - { - os << " = " << defaultIt->second; - } - else - { - os << " = { {" << defaultIt->second << "} }"; - } - } - os << " )" << std::endl - << " {" << std::endl - << " "; - if (it->second.members[i].arraySize.empty()) - { - os << it->second.members[i].name << " = " << it->second.members[i].name << "_"; - } - else - { - os << "memcpy( &" << it->second.members[i].name << ", " << it->second.members[i].name << "_.data(), " << it->second.members[i].arraySize << " * sizeof( " << it->second.members[i].type << " ) )"; - } - os << ";" << std::endl - << " }" << std::endl - << std::endl; - } - - for (size_t i = 0; isecond.members.size(); i++) - { - // one setter per union element - assert(!it->second.returnedOnly); - writeStructSetter(os, dependencyData.name, it->second.members[i]); - } - - // the implicit cast operator to the native type - os << " operator Vk" << dependencyData.name << " const& () const" << std::endl - << " {" << std::endl - << " return *reinterpret_cast(this);" << std::endl - << " }" << std::endl - << std::endl; - - // the union member variables - // if there's at least one Vk... type in this union, check for unrestricted unions support - bool needsUnrestrictedUnions = false; - for (size_t i = 0; i < it->second.members.size() && !needsUnrestrictedUnions; i++) - { - needsUnrestrictedUnions = (m_vkTypes.find(it->second.members[i].type) != m_vkTypes.end()); - } - if (needsUnrestrictedUnions) - { - os << "#ifdef VULKAN_HPP_HAS_UNRESTRICTED_UNIONS" << std::endl; - for (size_t i = 0; i < it->second.members.size(); i++) - { - os << " " << it->second.members[i].type << " " << it->second.members[i].name; - if (!it->second.members[i].arraySize.empty()) - { - os << "[" << it->second.members[i].arraySize << "]"; - } - os << ";" << std::endl; - } - os << "#else" << std::endl; - } - for (size_t i = 0; i < it->second.members.size(); i++) - { - os << " "; - if (m_vkTypes.find(it->second.members[i].type) != m_vkTypes.end()) - { - os << "Vk"; - } - os << it->second.members[i].type << " " << it->second.members[i].name; - if (!it->second.members[i].arraySize.empty()) - { - os << "[" << it->second.members[i].arraySize << "]"; - } - os << ";" << std::endl; - } - if (needsUnrestrictedUnions) - { - os << "#endif // VULKAN_HPP_HAS_UNRESTRICTED_UNIONS" << std::endl; - } - os << " };" << std::endl - << std::endl; -} - -#if !defined(NDEBUG) -void VulkanHppGenerator::checkExtensionRequirements() -{ - for (auto const& ext : m_extensions) - { - for (auto const& req : ext.second.requires) - { - auto reqExt = m_extensions.find(req); - assert(reqExt != m_extensions.end()); - assert(reqExt->second.protect.empty() || (reqExt->second.protect == ext.second.protect)); - } - } -} - -void VulkanHppGenerator::skipVendorID(tinyxml2::XMLElement const* element) -{ - std::map attributes = getAttributes(element); - checkAttributes(attributes, element->GetLineNum(), { { "comment",{} },{ "id",{} },{ "name",{} } }, {}); - checkElements(getChildElements(element), {}); - - VendorIDData vendorID; - for (auto const& attribute : attributes) - { - std::string name = attribute.first; - if (name == "comment") - { - vendorID.comment = attribute.second; - } - else if (name == "id") - { - vendorID.id = attribute.second; - } - else - { - assert(name == "name"); - vendorID.name = attribute.second; - } - } - m_vendorIDs.push_back(vendorID); -} - -void VulkanHppGenerator::skipVendorIDs(tinyxml2::XMLElement const* element) -{ - checkAttributes(getAttributes(element), element->GetLineNum(), { { "comment",{} } }, {}); - std::vector children = getChildElements(element); - checkElements(children, { "vendorid" }); - - for (auto child : children) - { - skipVendorID(child); - } -} -#endif - -void VulkanHppGenerator::EnumData::addEnumValue(std::string const &enumName, std::string const& tag, std::map & nameMap) -{ - EnumValueData evd; - evd.name = createEnumValueName(enumName, prefix, postfix, bitmask, tag); - evd.value = enumName; - - auto it = std::find_if(values.begin(), values.end(), [&evd](EnumValueData const& _evd) { return _evd.name == evd.name; }); - if (it == values.end()) - { - values.push_back(evd); - assert(nameMap.find(enumName) == nameMap.end()); - nameMap[enumName] = this->name + "::" + evd.name; - } - else - { - assert(it->value == evd.value); - } -} - -void VulkanHppGenerator::writeDelegationClassStatic(std::ostream &os) -{ - os << "class DispatchLoaderStatic" << std::endl - << "{" << std::endl - << "public:\n"; - - for (auto command : m_commands) - { - enterProtect(os, command.second.protect); - os << " " << command.second.unchangedReturnType << " vk" << startUpperCase(command.second.fullName) << "( "; - bool first = true; - for (auto param : command.second.params) - { - if (!first) { - os << ", "; - } - os << param.unchangedType << " " << param.name; - if (!param.arraySize.empty()) - { - os << "[" << param.arraySize << "]"; - } - first = false; - } - os << " ) const\n" - << " {\n" - << " return ::vk" << startUpperCase(command.second.fullName) << "( "; - first = true; - for (auto param : command.second.params) - { - if (!first) { - os << ", "; - } - os << param.name; - first = false; - } - os << ");\n"; - os << " }\n"; - leaveProtect(os, command.second.protect); - } - os << "};\n"; -} - -void VulkanHppGenerator::writeDelegationClassDynamic(std::ostream &os) -{ - os << " class DispatchLoaderDynamic" << std::endl - << " {" << std::endl - << " public:" << std::endl; - - for (auto command : m_commands) - { - enterProtect(os, command.second.protect); - os << " PFN_vk" << startUpperCase(command.second.fullName) << " vk" << startUpperCase(command.second.fullName) << " = 0;" << std::endl; - leaveProtect(os, command.second.protect); - } - - // write initialization function to fetch function pointers - os << " public:" << std::endl - << " DispatchLoaderDynamic(Instance instance = Instance(), Device device = Device())" << std::endl - << " {" << std::endl - << " if (instance)" << std::endl - << " {" << std::endl - << " init(instance, device);" << std::endl - << " }" << std::endl - << " }" << std::endl << std::endl - << " void init(Instance instance, Device device = Device())" << std::endl - << " {" << std::endl; - - for (auto command : m_commands) - { - enterProtect(os, command.second.protect); - if (!command.second.params.empty() - && m_handles.find(command.second.params[0].type) != m_handles.end() - && command.second.params[0].type != "Instance") - { - os << " vk" << startUpperCase(command.second.fullName) << " = PFN_vk" << startUpperCase(command.second.fullName) - << "(device ? device.getProcAddr( \"vk" << startUpperCase(command.second.fullName) << "\") : instance.getProcAddr( \"vk" << startUpperCase(command.second.fullName) << "\"));" << std::endl; - } - else { - os << " vk" << startUpperCase(command.second.fullName) << " = PFN_vk" << startUpperCase(command.second.fullName) << "(instance.getProcAddr( \"vk" << startUpperCase(command.second.fullName) << "\"));" << std::endl; - } - leaveProtect(os, command.second.protect); - } - os << " }" << std::endl; - os << " };\n"; -} - -int main( int argc, char **argv ) -{ - try { - tinyxml2::XMLDocument doc; - - std::string filename = (argc == 1) ? VK_SPEC : argv[1]; - std::cout << "Loading vk.xml from " << filename << std::endl; - std::cout << "Writing vulkan.hpp to " << VULKAN_HPP_FILE << std::endl; - - tinyxml2::XMLError error = doc.LoadFile(filename.c_str()); - if (error != tinyxml2::XML_SUCCESS) - { - std::cout << "VkGenerate: failed to load file " << filename << " . Error code: " << error << std::endl; - return -1; - } - - VulkanHppGenerator generator; - - bool foundLicense = false; - - tinyxml2::XMLElement const* registryElement = doc.FirstChildElement(); - checkAttributes(getAttributes(registryElement), registryElement->GetLineNum(), {}, {}); - assert(strcmp(registryElement->Value(), "registry") == 0); - assert(!registryElement->NextSiblingElement()); - - std::vector children = getChildElements(registryElement); - checkElements(children, { "commands", "comment", "enums", "extensions", "feature", "tags", "types", "vendorids", "platforms" }); - for (auto child : children) - { - const std::string value = child->Value(); - if (value == "commands") - { - generator.readCommands(child); - } - else if (value == "comment") - { - if (!foundLicense) - { - // get the vulkan license header and skip any leading spaces - generator.readComment(child); - foundLicense = true; - } - } - else if (value == "enums") - { - generator.readEnums(child); - } - else if (value == "extensions") - { - generator.readExtensions(child); - } - else if (value == "feature") - { - generator.readFeature(child); - } - else if (value == "tags") - { - generator.readTags(child); - } - else if (value == "types") - { - generator.readTypes(child); - } - else if (value == "vendorids") - { -#if !defined(NDEBUG) - generator.skipVendorIDs(child); -#endif - } - else if (value == "platforms") - { - // skip this tag - } - else - { - std::stringstream lineNumber; - lineNumber << child->GetLineNum(); - std::cerr << "warning: Unhandled tag " << value << " at line number: " << lineNumber.str() << "!" << std::endl; - } - } - - generator.sortDependencies(); - -#if !defined(NDEBUG) - generator.checkExtensionRequirements(); -#endif - - std::map defaultValues = generator.createDefaults(); - - std::ofstream ofs(VULKAN_HPP_FILE); - ofs << generator.getVulkanLicenseHeader() << std::endl - << R"( -#ifndef VULKAN_HPP -#define VULKAN_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE -# include -# include -#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ -#if !defined(VULKAN_HPP_ASSERT) -# include -# define VULKAN_HPP_ASSERT assert -#endif - -// includes through some other header -// this results in major(x) being resolved to gnu_dev_major(x) -// which is an expression in a constructor initializer list. -#if defined(major) - #undef major -#endif -#if defined(minor) - #undef minor -#endif - -// Windows defines MemoryBarrier which is deprecated and collides -// with the vk::MemoryBarrier struct. -#ifdef MemoryBarrier - #undef MemoryBarrier -#endif - -)"; - - writeVersionCheck(ofs, generator.getVersion()); - writeTypesafeCheck(ofs, generator.getTypesafeCheck()); - ofs << versionCheckHeader - << inlineHeader - << explicitHeader - << constExprHeader - << std::endl - << vkNamespace - << flagsHeader - << optionalClassHeader - << arrayProxyHeader - << uniqueHandleHeader - << structureChainHeader; - - // first of all, write out vk::Result and the exception handling stuff - generator.writeResultEnum(ofs); - - ofs << "} // namespace VULKAN_HPP_NAMESPACE" << std::endl - << std::endl - << "namespace std" << std::endl - << "{" << std::endl - << " template <>" << std::endl - << " struct is_error_code_enum : public true_type" << std::endl - << " {};" << std::endl - << "}" << std::endl - << std::endl - << "namespace VULKAN_HPP_NAMESPACE" << std::endl - << "{" << std::endl - << resultValueHeader - << createResultValueHeader; - generator.writeDelegationClassStatic(ofs); - ofs << deleterClassString; - - generator.writeTypes(ofs, defaultValues); - generator.writeStructureChainValidation(ofs); - generator.writeToStringFunctions(ofs); - - generator.writeDelegationClassDynamic(ofs); - - ofs << "} // namespace VULKAN_HPP_NAMESPACE" << std::endl - << std::endl - << "#endif" << std::endl; - } - catch (std::exception const& e) - { - std::cout << "caught exception: " << e.what() << std::endl; - return -1; - } - catch (...) - { - std::cout << "caught unknown exception" << std::endl; - return -1; - } -} +// Copyright(c) 2015-2016, NVIDIA CORPORATION. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "VulkanHppGenerator.hpp" + +const size_t INVALID_INDEX = (size_t)~0; + +const std::string vkNamespace = R"( +#if !defined(VULKAN_HPP_NAMESPACE) +#define VULKAN_HPP_NAMESPACE vk +#endif + +#define VULKAN_HPP_STRINGIFY2(text) #text +#define VULKAN_HPP_STRINGIFY(text) VULKAN_HPP_STRINGIFY2(text) +#define VULKAN_HPP_NAMESPACE_STRING VULKAN_HPP_STRINGIFY(VULKAN_HPP_NAMESPACE) + +namespace VULKAN_HPP_NAMESPACE +{ +)"; + +const std::string constExprHeader = R"( +#if defined(_MSC_VER) && (_MSC_VER <= 1800) +# define VULKAN_HPP_CONSTEXPR +#else +# define VULKAN_HPP_CONSTEXPR constexpr +#endif +)"; + +const std::string exceptionHeader = R"( +#if defined(_MSC_VER) && (_MSC_VER == 1800) +# define noexcept _NOEXCEPT +#endif + + class ErrorCategoryImpl : public std::error_category + { + public: + virtual const char* name() const noexcept override { return VULKAN_HPP_NAMESPACE_STRING"::Result"; } + virtual std::string message(int ev) const override { return to_string(static_cast(ev)); } + }; + +#if defined(_MSC_VER) && (_MSC_VER == 1800) +# undef noexcept +#endif + + VULKAN_HPP_INLINE const std::error_category& errorCategory() + { + static ErrorCategoryImpl instance; + return instance; + } + + VULKAN_HPP_INLINE std::error_code make_error_code(Result e) + { + return std::error_code(static_cast(e), errorCategory()); + } + + VULKAN_HPP_INLINE std::error_condition make_error_condition(Result e) + { + return std::error_condition(static_cast(e), errorCategory()); + } +)"; + +const std::string exceptionClassesHeader = R"( +#if defined(_MSC_VER) && (_MSC_VER == 1800) +# define noexcept _NOEXCEPT +#endif + + class Error + { + public: + virtual ~Error() = default; + + virtual const char* what() const noexcept = 0; + }; + + class LogicError : public Error, public std::logic_error + { + public: + explicit LogicError( const std::string& what ) + : Error(), std::logic_error(what) {} + explicit LogicError( char const * what ) + : Error(), std::logic_error(what) {} + virtual ~LogicError() = default; + + virtual const char* what() const noexcept { return std::logic_error::what(); } + }; + + class SystemError : public Error, public std::system_error + { + public: + SystemError( std::error_code ec ) + : Error(), std::system_error(ec) {} + SystemError( std::error_code ec, std::string const& what ) + : Error(), std::system_error(ec, what) {} + SystemError( std::error_code ec, char const * what ) + : Error(), std::system_error(ec, what) {} + SystemError( int ev, std::error_category const& ecat ) + : Error(), std::system_error(ev, ecat) {} + SystemError( int ev, std::error_category const& ecat, std::string const& what) + : Error(), std::system_error(ev, ecat, what) {} + SystemError( int ev, std::error_category const& ecat, char const * what) + : Error(), std::system_error(ev, ecat, what) {} + virtual ~SystemError() = default; + + virtual const char* what() const noexcept { return std::system_error::what(); } + }; + +#if defined(_MSC_VER) && (_MSC_VER == 1800) +# undef noexcept +#endif + +)"; + +const std::string flagsHeader = R"( + template struct FlagTraits + { + enum { allFlags = 0 }; + }; + + template + class Flags + { + public: + VULKAN_HPP_CONSTEXPR Flags() + : m_mask(0) + { + } + + Flags(BitType bit) + : m_mask(static_cast(bit)) + { + } + + Flags(Flags const& rhs) + : m_mask(rhs.m_mask) + { + } + + explicit Flags(MaskType flags) + : m_mask(flags) + { + } + + Flags & operator=(Flags const& rhs) + { + m_mask = rhs.m_mask; + return *this; + } + + Flags & operator|=(Flags const& rhs) + { + m_mask |= rhs.m_mask; + return *this; + } + + Flags & operator&=(Flags const& rhs) + { + m_mask &= rhs.m_mask; + return *this; + } + + Flags & operator^=(Flags const& rhs) + { + m_mask ^= rhs.m_mask; + return *this; + } + + Flags operator|(Flags const& rhs) const + { + Flags result(*this); + result |= rhs; + return result; + } + + Flags operator&(Flags const& rhs) const + { + Flags result(*this); + result &= rhs; + return result; + } + + Flags operator^(Flags const& rhs) const + { + Flags result(*this); + result ^= rhs; + return result; + } + + bool operator!() const + { + return !m_mask; + } + + Flags operator~() const + { + Flags result(*this); + result.m_mask ^= FlagTraits::allFlags; + return result; + } + + bool operator==(Flags const& rhs) const + { + return m_mask == rhs.m_mask; + } + + bool operator!=(Flags const& rhs) const + { + return m_mask != rhs.m_mask; + } + + explicit operator bool() const + { + return !!m_mask; + } + + explicit operator MaskType() const + { + return m_mask; + } + + private: + MaskType m_mask; + }; + + template + Flags operator|(BitType bit, Flags const& flags) + { + return flags | bit; + } + + template + Flags operator&(BitType bit, Flags const& flags) + { + return flags & bit; + } + + template + Flags operator^(BitType bit, Flags const& flags) + { + return flags ^ bit; + } + +)"; + +const std::string optionalClassHeader = R"( + template + class Optional + { + public: + Optional(RefType & reference) { m_ptr = &reference; } + Optional(RefType * ptr) { m_ptr = ptr; } + Optional(std::nullptr_t) { m_ptr = nullptr; } + + operator RefType*() const { return m_ptr; } + RefType const* operator->() const { return m_ptr; } + explicit operator bool() const { return !!m_ptr; } + + private: + RefType *m_ptr; + }; +)"; + +const std::string arrayProxyHeader = R"( +#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE + template + class ArrayProxy + { + public: + VULKAN_HPP_CONSTEXPR ArrayProxy(std::nullptr_t) + : m_count(0) + , m_ptr(nullptr) + {} + + ArrayProxy(T & ptr) + : m_count(1) + , m_ptr(&ptr) + {} + + ArrayProxy(uint32_t count, T * ptr) + : m_count(count) + , m_ptr(ptr) + {} + + template + ArrayProxy(std::array::type, N> & data) + : m_count(N) + , m_ptr(data.data()) + {} + + template + ArrayProxy(std::array::type, N> const& data) + : m_count(N) + , m_ptr(data.data()) + {} + + template ::type>> + ArrayProxy(std::vector::type, Allocator> & data) + : m_count(static_cast(data.size())) + , m_ptr(data.data()) + {} + + template ::type>> + ArrayProxy(std::vector::type, Allocator> const& data) + : m_count(static_cast(data.size())) + , m_ptr(data.data()) + {} + + ArrayProxy(std::initializer_list const& data) + : m_count(static_cast(data.end() - data.begin())) + , m_ptr(data.begin()) + {} + + const T * begin() const + { + return m_ptr; + } + + const T * end() const + { + return m_ptr + m_count; + } + + const T & front() const + { + VULKAN_HPP_ASSERT(m_count && m_ptr); + return *m_ptr; + } + + const T & back() const + { + VULKAN_HPP_ASSERT(m_count && m_ptr); + return *(m_ptr + m_count - 1); + } + + bool empty() const + { + return (m_count == 0); + } + + uint32_t size() const + { + return m_count; + } + + T * data() const + { + return m_ptr; + } + + private: + uint32_t m_count; + T * m_ptr; + }; +#endif +)"; + +const std::string structureChainHeader = R"( + + template struct isStructureChainValid { enum { value = false }; }; + + template + struct TypeList + { + using list = P; + using last = T; + }; + + template + struct extendCheck + { + static const bool valid = isStructureChainValid::value || extendCheck::valid; + }; + + template + struct extendCheck,X> + { + static const bool valid = isStructureChainValid::value; + }; + + template + struct extendCheck + { + static const bool valid = true; + }; + + template + class StructureChainElement + { + public: + explicit operator Element&() { return value; } + explicit operator const Element&() const { return value; } + private: + Element value; + }; + + template + class StructureChain : private StructureChainElement... + { + public: + StructureChain() + { + link(); + } + + StructureChain(StructureChain const &rhs) + { + linkAndCopy(rhs); + } + + StructureChain(StructureElements const &... elems) + { + linkAndCopyElements(elems...); + } + + StructureChain& operator=(StructureChain const &rhs) + { + linkAndCopy(rhs); + return *this; + } + + template ClassType& get() { return static_cast(*this);} + + private: + template + void link() + { + static_assert(extendCheck::valid, "The structure chain is not valid!"); + } + + template + void link() + { + static_assert(extendCheck::valid, "The structure chain is not valid!"); + X& x = static_cast(*this); + Y& y = static_cast(*this); + x.pNext = &y; + link, Y, Z...>(); + } + + template + void linkAndCopy(StructureChain const &rhs) + { + static_assert(extendCheck::valid, "The structure chain is not valid!"); + static_cast(*this) = static_cast(rhs); + } + + template + void linkAndCopy(StructureChain const &rhs) + { + static_assert(extendCheck::valid, "The structure chain is not valid!"); + X& x = static_cast(*this); + Y& y = static_cast(*this); + x = static_cast(rhs); + x.pNext = &y; + linkAndCopy, Y, Z...>(rhs); + } + + template + void linkAndCopyElements(X const &xelem) + { + static_assert(extendCheck::valid, "The structure chain is not valid!"); + static_cast(*this) = xelem; + } + + template + void linkAndCopyElements(X const &xelem, Y const &yelem, Z const &... zelem) + { + static_assert(extendCheck::valid, "The structure chain is not valid!"); + X& x = static_cast(*this); + Y& y = static_cast(*this); + x = xelem; + x.pNext = &y; + linkAndCopyElements, Y, Z...>(yelem, zelem...); + } + }; + +)"; + +const std::string versionCheckHeader = R"( +#if !defined(VULKAN_HPP_HAS_UNRESTRICTED_UNIONS) +# if defined(__clang__) +# if __has_feature(cxx_unrestricted_unions) +# define VULKAN_HPP_HAS_UNRESTRICTED_UNIONS +# endif +# elif defined(__GNUC__) +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# if 40600 <= GCC_VERSION +# define VULKAN_HPP_HAS_UNRESTRICTED_UNIONS +# endif +# elif defined(_MSC_VER) +# if 1900 <= _MSC_VER +# define VULKAN_HPP_HAS_UNRESTRICTED_UNIONS +# endif +# endif +#endif +)"; + +const std::string inlineHeader = R"( +#if !defined(VULKAN_HPP_INLINE) +# if defined(__clang___) +# if __has_attribute(always_inline) +# define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__ +# else +# define VULKAN_HPP_INLINE inline +# endif +# elif defined(__GNUC__) +# define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__ +# elif defined(_MSC_VER) +# define VULKAN_HPP_INLINE inline +# else +# define VULKAN_HPP_INLINE inline +# endif +#endif +)"; + +const std::string explicitHeader = R"( +#if defined(VULKAN_HPP_TYPESAFE_CONVERSION) +# define VULKAN_HPP_TYPESAFE_EXPLICIT +#else +# define VULKAN_HPP_TYPESAFE_EXPLICIT explicit +#endif +)"; + +const std::string resultValueHeader = R"( + template + struct ResultValue + { + ResultValue( Result r, T & v ) + : result( r ) + , value( v ) + {} + + ResultValue( Result r, T && v ) + : result( r ) + , value( std::move( v ) ) + {} + + Result result; + T value; + + operator std::tuple() { return std::tuple(result, value); } + }; + + template + struct ResultValueType + { +#ifdef VULKAN_HPP_NO_EXCEPTIONS + typedef ResultValue type; +#else + typedef T type; +#endif + }; + + template <> + struct ResultValueType + { +#ifdef VULKAN_HPP_NO_EXCEPTIONS + typedef Result type; +#else + typedef void type; +#endif + }; +)"; + +const std::string createResultValueHeader = R"( + VULKAN_HPP_INLINE ResultValueType::type createResultValue( Result result, char const * message ) + { +#ifdef VULKAN_HPP_NO_EXCEPTIONS + VULKAN_HPP_ASSERT( result == Result::eSuccess ); + return result; +#else + if ( result != Result::eSuccess ) + { + throwResultException( result, message ); + } +#endif + } + + template + VULKAN_HPP_INLINE typename ResultValueType::type createResultValue( Result result, T & data, char const * message ) + { +#ifdef VULKAN_HPP_NO_EXCEPTIONS + VULKAN_HPP_ASSERT( result == Result::eSuccess ); + return ResultValue( result, data ); +#else + if ( result != Result::eSuccess ) + { + throwResultException( result, message ); + } + return std::move( data ); +#endif + } + + VULKAN_HPP_INLINE Result createResultValue( Result result, char const * message, std::initializer_list successCodes ) + { +#ifdef VULKAN_HPP_NO_EXCEPTIONS + VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); +#else + if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) + { + throwResultException( result, message ); + } +#endif + return result; + } + + template + VULKAN_HPP_INLINE ResultValue createResultValue( Result result, T & data, char const * message, std::initializer_list successCodes ) + { +#ifdef VULKAN_HPP_NO_EXCEPTIONS + VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); +#else + if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) + { + throwResultException( result, message ); + } +#endif + return ResultValue( result, data ); + } + +#ifndef VULKAN_HPP_NO_SMART_HANDLE + template + VULKAN_HPP_INLINE typename ResultValueType>::type createResultValue( Result result, T & data, char const * message, typename UniqueHandleTraits::deleter const& deleter ) + { +#ifdef VULKAN_HPP_NO_EXCEPTIONS + VULKAN_HPP_ASSERT( result == Result::eSuccess ); + return ResultValue>( result, UniqueHandle(data, deleter) ); +#else + if ( result != Result::eSuccess ) + { + throwResultException( result, message ); + } + return UniqueHandle(data, deleter); +#endif + } +#endif + +)"; + +const std::string uniqueHandleHeader = R"( +#ifndef VULKAN_HPP_NO_SMART_HANDLE + + template class UniqueHandleTraits; + + template + class UniqueHandle : public UniqueHandleTraits::deleter + { + private: + using Owner = typename UniqueHandleTraits::owner; + using Deleter = typename UniqueHandleTraits::deleter; + public: + + explicit UniqueHandle( Type const& value = Type() ) + : UniqueHandle(value, Deleter()) + {} + + explicit UniqueHandle( Type const& value, Deleter const& deleter = Deleter() ) + : Deleter( deleter) + , m_value( value ) + {} + + explicit UniqueHandle( Type const& value, Owner const& owner = Owner() ) + : Deleter( owner) + , m_value( value ) + {} + + UniqueHandle( UniqueHandle const& ) = delete; + + UniqueHandle( UniqueHandle && other ) + : Deleter( std::move( static_cast( other ) ) ) + , m_value( other.release() ) + {} + + ~UniqueHandle() + { + if ( m_value ) this->destroy( m_value ); + } + + UniqueHandle & operator=( UniqueHandle const& ) = delete; + + UniqueHandle & operator=( UniqueHandle && other ) + { + reset( other.release() ); + *static_cast(this) = std::move( static_cast(other) ); + return *this; + } + + explicit operator bool() const + { + return m_value.operator bool(); + } + + Type const* operator->() const + { + return &m_value; + } + + Type * operator->() + { + return &m_value; + } + + Type const& operator*() const + { + return m_value; + } + + Type & operator*() + { + return m_value; + } + + const Type & get() const + { + return m_value; + } + + Type & get() + { + return m_value; + } + + void reset( Type const& value = Type() ) + { + if ( m_value != value ) + { + if ( m_value ) this->destroy( m_value ); + m_value = value; + } + } + + Type release() + { + Type value = m_value; + m_value = nullptr; + return value; + } + + void swap( UniqueHandle & rhs ) + { + std::swap(m_value, rhs.m_value); + std::swap(static_cast(*this), static_cast(rhs)); + } + + private: + Type m_value; + }; + + template + VULKAN_HPP_INLINE void swap( UniqueHandle & lhs, UniqueHandle & rhs ) + { + lhs.swap( rhs ); + } +#endif + +)"; + +const std::string deleterClassString = R"( + struct AllocationCallbacks; + + template + class ObjectDestroy + { + public: + ObjectDestroy( OwnerType owner = OwnerType(), Optional allocator = nullptr, Dispatch const &dispatch = Dispatch() ) + : m_owner( owner ) + , m_allocator( allocator ) + , m_dispatch( &dispatch ) + {} + + OwnerType getOwner() const { return m_owner; } + Optional getAllocator() const { return m_allocator; } + + protected: + template + void destroy(T t) + { + m_owner.destroy( t, m_allocator, *m_dispatch ); + } + + private: + OwnerType m_owner; + Optional m_allocator; + Dispatch const* m_dispatch; + }; + + class NoParent; + + template + class ObjectDestroy + { + public: + ObjectDestroy( Optional allocator = nullptr, Dispatch const &dispatch = Dispatch() ) + : m_allocator( allocator ) + , m_dispatch( &dispatch ) + {} + + Optional getAllocator() const { return m_allocator; } + + protected: + template + void destroy(T t) + { + t.destroy( m_allocator, *m_dispatch ); + } + + private: + Optional m_allocator; + Dispatch const* m_dispatch; + }; + + template + class ObjectFree + { + public: + ObjectFree( OwnerType owner = OwnerType(), Optional allocator = nullptr, Dispatch const &dispatch = Dispatch() ) + : m_owner( owner ) + , m_allocator( allocator ) + , m_dispatch( &dispatch ) + {} + + OwnerType getOwner() const { return m_owner; } + Optional getAllocator() const { return m_allocator; } + + protected: + template + void destroy(T t) + { + m_owner.free( t, m_allocator, *m_dispatch ); + } + + private: + OwnerType m_owner; + Optional m_allocator; + Dispatch const* m_dispatch; + }; + + template + class PoolFree + { + public: + PoolFree( OwnerType owner = OwnerType(), PoolType pool = PoolType(), Dispatch const &dispatch = Dispatch() ) + : m_owner( owner ) + , m_pool( pool ) + , m_dispatch( &dispatch ) + {} + + OwnerType getOwner() const { return m_owner; } + PoolType getPool() const { return m_pool; } + + protected: + template + void destroy(T t) + { + m_owner.free( m_pool, t, *m_dispatch ); + } + + private: + OwnerType m_owner; + PoolType m_pool; + Dispatch const* m_dispatch; + }; + +)"; + + +std::string replaceWithMap(std::string const &input, std::map replacements) +{ + // This will match ${someVariable} and contain someVariable in match group 1 + std::regex re(R"(\$\{([^\}]+)\})"); + auto it = std::sregex_iterator(input.begin(), input.end(), re); + auto end = std::sregex_iterator(); + + // No match, just return the original string + if (it == end) + { + return input; + } + + std::string result = ""; + while (it != end) + { + std::smatch match = *it; + auto itReplacement = replacements.find(match[1].str()); + assert(itReplacement != replacements.end()); + + result += match.prefix().str() + ((itReplacement != replacements.end()) ? itReplacement->second : match[0].str()); + ++it; + + // we've passed the last match. Append the rest of the orignal string + if (it == end) + { + result += match.suffix().str(); + } + } + return result; +} + + +bool beginsWith(std::string const& text, std::string const& prefix); +void checkAttributes(std::map const& attributes, int line, std::map> const& required, std::map> const& optional); +void checkElements(std::vector const& elements, std::set const& values); +void checkEmptyElement(tinyxml2::XMLElement const* element); +void checkOrderedElements(std::vector const& elements, std::vector const& values); +std::string createEnumValueName(std::string const& name, std::string const& prefix, std::string const& postfix, bool bitmask, std::string const& tag); +bool endsWith(std::string const& text, std::string const& postfix); +void enterProtect(std::ostream &os, std::string const& protect); +std::string extractTag(std::string const& name); +std::string findTag(std::string const& name, std::set const& tags); +std::string generateEnumNameForFlags(std::string const& name); +std::map getAttributes(tinyxml2::XMLElement const* element); +std::vector getChildElements(tinyxml2::XMLElement const* element); +bool isErrorEnum(std::string const& enumName); +void leaveProtect(std::ostream &os, std::string const& protect); +std::string readArraySize(tinyxml2::XMLNode const* node, std::string& name); +std::string startUpperCase(std::string const& input); +std::string startLowerCase(std::string const& input); +std::string strip(std::string const& value, std::string const& prefix, std::string const& postfix = std::string()); +std::string stripErrorEnumPrefix(std::string const& enumName); +std::string stripPluralS(std::string const& name); +std::vector tokenize(std::string tokenString, char separator); +std::string trim(std::string const& input); +std::string trimEnd(std::string const& input); +std::string toCamelCase(std::string const& value); +std::string toUpperCase(std::string const& name); +void writeFunctionHeaderName(std::ostream & os, std::string const& name, bool singular, bool unique); +void writeReinterpretCast(std::ostream & os, bool leadingConst, bool vulkanType, std::string const& type, bool trailingPointerToConst); +void writeStandardOrEnhanced(std::ostream & os, std::string const& standard, std::string const& enhanced); +void writeTypesafeCheck(std::ostream & os, std::string const& typesafeCheck); +void writeVersionCheck(std::ostream & os, std::string const& version); +#if !defined(NDEBUG) +void skipFeatureRequire(tinyxml2::XMLElement const* element); +void skipImplicitExternSyncParams(tinyxml2::XMLElement const* element); +void skipTypeEnum(tinyxml2::XMLElement const* element, std::map const& attributes); +void skipTypeInclude(tinyxml2::XMLElement const* element); +#endif + +bool beginsWith(std::string const& text, std::string const& prefix) +{ + return !prefix.empty() && text.substr(0, prefix.length()) == prefix; +} + +// check the validity of an attributes map +// attributes : the map of name/value pairs of the encountered attributes +// line : the line in the xml file where the attributes are listed +// required : the required attributes, with a set of allowed values per attribute +// optional : the optional attributes, with a set of allowed values per attribute +void checkAttributes(std::map const& attributes, int line, std::map> const& required, std::map> const& optional) +{ + std::stringstream ss; + ss << line; + std::string lineNumber = ss.str(); + + // check if all required attributes are included and if there is a set of allowed values, check if the actual value is part of that set + for (auto const& r : required) + { + auto attributesIt = attributes.find(r.first); + if (attributesIt == attributes.end()) + { + throw std::runtime_error("Spec error on line " + lineNumber + ": missing attribute <" + r.first + ">"); + } + if (!r.second.empty() && (r.second.find(attributesIt->second) == r.second.end())) + { + throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected attribute value <" + attributesIt->second + "> in attribute <" + r.first + ">"); + } + } + // check if all not required attributes or optional, and if there is a set of allowed values, check if the actual value is part of that set + for (auto const& a : attributes) + { + if (required.find(a.first) == required.end()) + { + auto optionalIt = optional.find(a.first); + if (optionalIt == optional.end()) + { + std::cerr << "warning: " << "Unknown attribute " + a.first + " in line " + lineNumber + "!" << std::endl; + continue; + } + if (!optionalIt->second.empty()) + { + std::vector values = tokenize(a.second, ','); + for (auto const& v : values) + { + if (optionalIt->second.find(v) == optionalIt->second.end()) + { + throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected attribute value <" + v + "> in attribute <" + a.first + ">"); + } + } + } + } + } +} + +void checkElements(std::vector const& elements, std::set const& values) +{ + for (auto e : elements) + { + if (values.find(e->Value()) == values.end()) + { + std::stringstream ss; + ss << e->GetLineNum(); + std::string lineNumber = ss.str(); + std::cerr << "warning: Unknown element in spec on line: " << lineNumber << " " << e->Value() << "!" << std::endl; + } + } +} + +void checkEmptyElement(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); + checkElements(getChildElements(element), {}); +} + +void checkOrderedElements(std::vector const& elements, std::vector const& values) +{ + for (size_t i = 0; i < elements.size(); i++) + { + std::stringstream ss; + ss << elements[i]->GetLineNum(); + std::string lineNumber = ss.str(); + + if (values.size() <= i) + { + throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected surplus element <" + elements[i]->Value() + ">"); + } + if (values[i] != elements[i]->Value()) + { + throw std::runtime_error("Spec error on line " + lineNumber + ": unexpected element <" + elements[i]->Value() + ">, expected <" + values[i] + ">"); + } + } +} + +std::string createEnumValueName(std::string const& name, std::string const& prefix, std::string const& postfix, bool bitmask, std::string const& tag) +{ + std::string result = "e" + toCamelCase(strip(name, prefix, postfix)); + if (bitmask) + { + size_t pos = result.find("Bit"); + if (pos != std::string::npos) + { + result.erase(pos, 3); + } + } + if (!tag.empty() && (result.substr(result.length() - tag.length()) == toCamelCase(tag))) + { + result = result.substr(0, result.length() - tag.length()) + tag; + } + return result; +} + +bool endsWith(std::string const& text, std::string const& postfix) +{ + return !postfix.empty() && (postfix.length() < text.length()) && (text.substr(text.length() - postfix.length()) == postfix); +} + +void enterProtect(std::ostream &os, std::string const& protect) +{ + if (!protect.empty()) + { + os << "#ifdef " << protect << std::endl; + } +} + +std::string extractTag(std::string const& name) +{ + // the name is supposed to look like: VK__ + size_t start = name.find('_'); + assert((start != std::string::npos) && (name.substr(0, start) == "VK")); + size_t end = name.find('_', start + 1); + assert(end != std::string::npos); + return name.substr(start + 1, end - start - 1); +} + +std::string findTag(std::string const& name, std::set const& tags) +{ + // find the tag in a name, return that tag or an empty string + auto tagIt = std::find_if(tags.begin(), tags.end(), [&name](std::string const& t) + { + size_t pos = name.find(t); + return (pos != std::string::npos) && (pos == name.length() - t.length()); + }); + return tagIt != tags.end() ? *tagIt : ""; +} + +std::string generateEnumNameForFlags(std::string const& name) +{ + // create a string, where the substring "Flags" is replaced by "FlagBits" + std::string generatedName = name; + size_t pos = generatedName.rfind("Flags"); + assert(pos != std::string::npos); + generatedName.replace(pos, 5, "FlagBits"); + return generatedName; +} + +std::map getAttributes(tinyxml2::XMLElement const* element) +{ + std::map attributes; + for (auto attribute = element->FirstAttribute(); attribute; attribute = attribute->Next()) + { + assert(attributes.find(attribute->Name()) == attributes.end()); + attributes[attribute->Name()] = attribute->Value(); + } + return attributes; +} + +std::vector getChildElements(tinyxml2::XMLElement const* element) +{ + std::vector childElements; + for (tinyxml2::XMLElement const* childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) + { + childElements.push_back(childElement); + } + return childElements; +} + +bool isErrorEnum(std::string const& enumName) +{ + return (enumName.substr(0, 6) == "eError"); +} + +void leaveProtect(std::ostream &os, std::string const& protect) +{ + if (!protect.empty()) + { + os << "#endif /*" << protect << "*/" << std::endl; + } +} + +std::string readArraySize(tinyxml2::XMLNode const* node, std::string& name) +{ + std::string arraySize; + if (name.back() == ']') + { + // if the parameter has '[' and ']' in its name, get the stuff inbetween those as the array size and erase that part from the parameter name + assert(!node->NextSibling()); + size_t pos = name.find('['); + assert(pos != std::string::npos); + arraySize = name.substr(pos + 1, name.length() - 2 - pos); + name.erase(pos); + } + else + { + // otherwise look for a sibling of this node + node = node->NextSibling(); + if (node && node->ToText()) + { + assert(node->Value()); + std::string value = trimEnd(node->Value()); + if (value == "[") + { + // if this node has '[' as its value, the next node holds the array size, and the node after that needs to hold ']', and there should be no more siblings + node = node->NextSibling(); + assert(node && node->ToElement() && (strcmp(node->Value(), "enum") == 0)); + arraySize = node->ToElement()->GetText(); + node = node->NextSibling(); + assert(node && node->ToText() && (trimEnd(node->Value()) == "]")); + } + else + { + // otherwise, the node holds '[' and ']', so get the stuff in between those as the array size + assert((value.front() == '[') && (value.back() == ']')); + arraySize = value.substr(1, value.length() - 2); + } + assert(!node->NextSibling() || ((strcmp(node->NextSibling()->Value(), "comment") == 0) && !node->NextSibling()->NextSibling())); + } + } + return arraySize; +} + +std::string startUpperCase(std::string const& input) +{ + return static_cast(toupper(input[0])) + input.substr(1); +} + +std::string startLowerCase(std::string const& input) +{ + return input.empty() ? "" : static_cast(tolower(input[0])) + input.substr(1); +} + +std::string strip(std::string const& value, std::string const& prefix, std::string const& postfix) +{ + std::string strippedValue = value; + if (beginsWith(strippedValue, prefix)) + { + strippedValue.erase(0, prefix.length()); + } + if (endsWith(strippedValue, postfix)) + { + strippedValue.erase(strippedValue.length() - postfix.length()); + } + return strippedValue; +} + +std::string stripErrorEnumPrefix(std::string const& enumName) +{ + assert(isErrorEnum(enumName)); + return strip(enumName, "eError"); +} + +std::string stripPluralS(std::string const& name) +{ + std::string strippedName(name); + size_t pos = strippedName.rfind('s'); + assert(pos != std::string::npos); + strippedName.erase(pos, 1); + return strippedName; +} + +std::vector tokenize(std::string tokenString, char separator) +{ + std::vector tokens; + size_t start = 0, end; + do + { + end = tokenString.find(separator, start); + tokens.push_back(tokenString.substr(start, end - start)); + start = end + 1; + } while (end != std::string::npos); + return tokens; +} + +std::string trim(std::string const& input) +{ + std::string result = input; + result.erase(result.begin(), std::find_if(result.begin(), result.end(), [](char c) { return !std::isspace(c); })); + result.erase(std::find_if(result.rbegin(), result.rend(), [](char c) { return !std::isspace(c); }).base(), result.end()); + return result; +} + +std::string trimEnd(std::string const& input) +{ + std::string result = input; + result.erase(std::find_if(result.rbegin(), result.rend(), [](char c) { return !std::isspace(c); }).base(), result.end()); + return result; +} + +std::string toCamelCase(std::string const& value) +{ + assert(!value.empty() && (isupper(value[0]) || isdigit(value[0]))); + std::string result; + result.reserve(value.size()); + result.push_back(value[0]); + for (size_t i = 1; i < value.size(); i++) + { + if (value[i] != '_') + { + if ((value[i - 1] == '_') || isdigit(value[i - 1])) + { + result.push_back(value[i]); + } + else + { + result.push_back(static_cast(tolower(value[i]))); + } + } + } + return result; +} + +std::string toUpperCase(std::string const& name) +{ + std::string convertedName; + + for (size_t i = 0; i(toupper(name[i]))); + } + return convertedName; +} + +void writeFunctionHeaderName(std::ostream & os, std::string const& name, bool singular, bool unique) +{ + os << (singular ? stripPluralS(name) : name); + if (unique) + { + os << "Unique"; + } +} + +void writeReinterpretCast(std::ostream & os, bool leadingConst, bool vulkanType, std::string const& type, bool trailingPointerToConst) +{ + os << "reinterpret_cast<"; + if (leadingConst) + { + os << "const "; + } + if (vulkanType) + { + os << "Vk"; + } + os << type; + if (trailingPointerToConst) + { + os << "* const"; + } + os << "*>"; +} + +void writeStandardOrEnhanced(std::ostream & os, std::string const& standard, std::string const& enhanced) +{ + if (standard == enhanced) + { + // standard and enhanced string are equal -> just use one of them and we're done + os << standard; + } + else + { + // standard and enhanced string differ -> use both, wrapping the enhanced by !VULKAN_HPP_DISABLE_ENHANCED_MODE + // determine the argument list of that standard, and compare it with that of the enhanced + // if they are equal -> need to have just one; if they differ -> need to have both + size_t standardStart = standard.find('('); + size_t standardCount = standard.find(')', standardStart) - standardStart; + size_t enhancedStart = enhanced.find('('); + bool unchangedInterface = (standard.substr(standardStart, standardCount) == enhanced.substr(enhancedStart, standardCount)); + if (unchangedInterface) + { + os << "#ifdef VULKAN_HPP_DISABLE_ENHANCED_MODE" << std::endl; + } + os << standard + << (unchangedInterface ? "#else" : "#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE") << std::endl + << enhanced + << "#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/" << std::endl; + } +} + +void writeTypesafeCheck(std::ostream & os, std::string const& typesafeCheck) +{ + os << "// 32-bit vulkan is not typesafe for handles, so don't allow copy constructors on this platform by default." << std::endl + << "// To enable this feature on 32-bit platforms please define VULKAN_HPP_TYPESAFE_CONVERSION" << std::endl + << typesafeCheck << std::endl + << "# if !defined( VULKAN_HPP_TYPESAFE_CONVERSION )" << std::endl + << "# define VULKAN_HPP_TYPESAFE_CONVERSION" << std::endl + << "# endif" << std::endl + << "#endif" << std::endl; +} + +void writeVersionCheck(std::ostream & os, std::string const& version) +{ + os << "static_assert( VK_HEADER_VERSION == " << version << " , \"Wrong VK_HEADER_VERSION!\" );" << std::endl + << std::endl; +} + +#if !defined(NDEBUG) +void skipFeatureRequire(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), {}, { { "name",{} } }); + checkElements(getChildElements(element), {}); +} + +void skipImplicitExternSyncParams(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); + std::vector children = getChildElements(element); + checkOrderedElements(children, { "param" }); + checkEmptyElement(children[0]); +} + +void skipTypeEnum(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { { "category",{ "enum" } } }, { { "alias", {} }, { "name",{} } }); + checkElements(getChildElements(element), {}); +} + +void skipTypeInclude(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), { { "category",{ "include" } } }, { { "name",{} } }); + std::vector children = getChildElements(element); + checkElements(children, { "name" }); + + for (auto child : children) + { + checkEmptyElement(child); + } +} +#endif + +template +void VulkanHppGenerator::checkAlias(std::map const& data, std::string const& name, int line) +{ + if (data.find(name) == data.end()) + { + std::stringstream ss; + ss << line; + std::string lineNumber = ss.str(); + + throw std::runtime_error("Spec error on line " + lineNumber + ": missing alias <" + name + ">"); + } +} + +bool VulkanHppGenerator::containsUnion(std::string const& type, std::map const& structs) +{ + // a simple recursive check if a type is or contains a union + std::map::const_iterator sit = structs.find(type); + bool found = (sit != structs.end()); + if (found) + { + found = sit->second.isUnion; + for (std::vector::const_iterator mit = sit->second.members.begin(); mit != sit->second.members.end() && !found; ++mit) + { + found = (mit->type == mit->pureType) && containsUnion(mit->type, structs); + } + } + return found; +} + +std::map VulkanHppGenerator::createDefaults() +{ + std::map defaultValues; + for (auto const& dependency : m_dependencies) + { + assert(defaultValues.find(dependency.name) == defaultValues.end()); + switch (dependency.category) + { + case DependencyData::Category::BITMASK: + case DependencyData::Category::HANDLE: + case DependencyData::Category::STRUCT: + case DependencyData::Category::UNION: // just call the default constructor for bitmasks, handles, structs, and unions (which are mapped to classes) + defaultValues[dependency.name] = dependency.name + "()"; + break; + case DependencyData::Category::COMMAND: // commands should never be asked for defaults + break; + case DependencyData::Category::ENUM: + assert(m_enums.find(dependency.name) != m_enums.end()); + setDefault(dependency.name, defaultValues, m_enums.find(dependency.name)->second); + break; + case DependencyData::Category::FUNC_POINTER: // func_pointers default to nullptr + defaultValues[dependency.name] = "nullptr"; + break; + case DependencyData::Category::REQUIRED: // all required default to "0" + case DependencyData::Category::SCALAR: // all scalars default to "0" + defaultValues[dependency.name] = "0"; + break; + default: + assert(false && "Unhandled exception category"); + break; + } + } + return defaultValues; +} + +void VulkanHppGenerator::determineEnhancedReturnType(CommandData & commandData) +{ + std::string returnType; + // if there is a return parameter of type void or Result, and if it's of type Result it either has just one success code + // or two success codes, where the second one is of type eIncomplete and it's a two-step process + // -> we can return that parameter + if ((commandData.returnParam != INVALID_INDEX) + && ((commandData.returnType == "void") + || ((commandData.returnType == "Result") + && ((commandData.successCodes.size() == 1) + || ((commandData.successCodes.size() == 2) + && (commandData.successCodes[1] == "eIncomplete") + && commandData.twoStep))))) + { + if (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end()) + { + // the return parameter is a vector-type parameter + if (commandData.params[commandData.returnParam].pureType == "void") + { + // for a vector of void, we use a vector of uint8_t, instead + commandData.enhancedReturnType = "std::vector"; + } + else + { + // for the other parameters, we use a vector of the pure type + commandData.enhancedReturnType = "std::vector<" + commandData.params[commandData.returnParam].pureType + ",Allocator>"; + } + } + else + { + // it's a simple parameter -> get the type and just remove the trailing '*' (originally, it's a pointer) + assert(commandData.params[commandData.returnParam].type.back() == '*'); + assert(commandData.params[commandData.returnParam].type.find("const") == std::string::npos); + commandData.enhancedReturnType = commandData.params[commandData.returnParam].type; + commandData.enhancedReturnType.pop_back(); + } + } + else if ((commandData.returnType == "Result") && (commandData.successCodes.size() == 1)) + { + // an original return of type "Result" with just one successCode is changed to void, errors throw an exception + commandData.enhancedReturnType = "void"; + } + else + { + // the return type just stays the original return type + commandData.enhancedReturnType = commandData.returnType; + } +} + +void VulkanHppGenerator::determineReducedName(CommandData & commandData) +{ + commandData.reducedName = commandData.fullName; + std::string searchName = commandData.params[0].pureType; + size_t pos = commandData.fullName.find(searchName); + if ((pos == std::string::npos) && isupper(searchName[0])) + { + searchName[0] = static_cast(tolower(searchName[0])); + pos = commandData.fullName.find(searchName); + } + if (pos != std::string::npos) + { + commandData.reducedName.erase(pos, searchName.length()); + } + else if ((searchName == "commandBuffer") && (commandData.fullName.find("cmd") == 0)) + { + commandData.reducedName.erase(0, 3); + pos = 0; + } + if ((pos == 0) && isupper(commandData.reducedName[0])) + { + commandData.reducedName[0] = static_cast(tolower(commandData.reducedName[0])); + } +} + +void VulkanHppGenerator::determineReturnParam(CommandData & commandData) +{ + // for return types of type Result or void, we can replace determine a parameter to return + if ((commandData.returnType == "Result") || (commandData.returnType == "void")) + { + for (size_t i = 0; i < commandData.params.size(); i++) + { + if ((commandData.params[i].type.find('*') != std::string::npos) + && (commandData.params[i].type.find("const") == std::string::npos) + && std::find_if(commandData.vectorParams.begin(), commandData.vectorParams.end(), [i](std::pair const& vp) { return vp.second == i; }) == commandData.vectorParams.end()) + { + // it's a non-const pointer and not a vector-size parameter + std::map::const_iterator vpit = commandData.vectorParams.find(i); + if ((vpit == commandData.vectorParams.end()) || commandData.twoStep || (commandData.vectorParams.size() > 1) || (vpit->second == INVALID_INDEX) || (commandData.params[vpit->second].type.find('*') != std::string::npos)) + { + // it's not a vector parameter, or a two-step process, or there is at least one more vector parameter, or the size argument of this vector parameter is not an argument, or the size argument of this vector parameter is provided by a pointer + // -> look for another non-cost pointer argument + auto paramIt = std::find_if(commandData.params.begin() + i + 1, commandData.params.end(), [](ParamData const& pd) + { + return (pd.type.find('*') != std::string::npos) && (pd.type.find("const") == std::string::npos); + }); + // if there is another such argument, we can't decide which one to return -> return INVALID_INDEX + // otherwise return the index of the selcted parameter + commandData.returnParam = paramIt != commandData.params.end() ? ~0 : i; + } + } + } + } +} + +void VulkanHppGenerator::determineSkippedParams(CommandData & commandData) +{ + // the size-parameters of vector parameters are not explicitly used in the enhanced API + std::for_each(commandData.vectorParams.begin(), commandData.vectorParams.end(), [&commandData](std::pair const& vp) { if (vp.second != INVALID_INDEX) commandData.skippedParams.insert(vp.second); }); + // and the return parameter is also skipped + if (commandData.returnParam != INVALID_INDEX) + { + commandData.skippedParams.insert(commandData.returnParam); + } +} + +void VulkanHppGenerator::determineTemplateParam(CommandData & commandData) +{ + for (size_t i = 0; i < commandData.params.size(); i++) + { + // any vector parameter on the pure type void is templatized in the enhanced API + if ((commandData.vectorParams.find(i) != commandData.vectorParams.end()) && (commandData.params[i].pureType == "void")) + { +#if !defined(NDEBUG) + for (size_t j = i + 1; j < commandData.params.size(); j++) + { + assert((commandData.vectorParams.find(j) == commandData.vectorParams.end()) || (commandData.params[j].pureType != "void")); + } +#endif + commandData.templateParam = i; + break; + } + } + assert((commandData.templateParam == INVALID_INDEX) || (commandData.vectorParams.find(commandData.templateParam) != commandData.vectorParams.end())); +} + +void VulkanHppGenerator::determineVectorParams(CommandData & commandData) +{ + // look for the parameters whose len equals the name of an other parameter + for (auto it = commandData.params.begin(), begin = it, end = commandData.params.end(); it != end; ++it) + { + if (!it->len.empty()) + { + auto findLambda = [it](ParamData const& pd) { return pd.name == it->len; }; + auto findIt = std::find_if(begin, it, findLambda); // look for a parameter named as the len of this parameter + assert((std::count_if(begin, end, findLambda) == 0) || (findIt < it)); // make sure, there is no other parameter like that + + // add this parameter as a vector parameter, using the len-name parameter as the second value (or INVALID_INDEX if there is nothing like that) + commandData.vectorParams.insert(std::make_pair(std::distance(begin, it), findIt < it ? std::distance(begin, findIt) : INVALID_INDEX)); + assert((commandData.vectorParams[std::distance(begin, it)] != INVALID_INDEX) + || (it->len == "null-terminated") + || (it->len == "pAllocateInfo::descriptorSetCount") + || (it->len == "pAllocateInfo::commandBufferCount")); + } + } +} + +std::string VulkanHppGenerator::generateCall(CommandData const& commandData, bool firstCall, bool singular) +{ + std::ostringstream call; + writeCall(call, commandData, firstCall, singular); + return call.str(); +} + +std::string const& VulkanHppGenerator::getTypesafeCheck() const +{ + return m_typesafeCheck; +} + +std::string const& VulkanHppGenerator::getVersion() const +{ + return m_version; +} + +std::string const& VulkanHppGenerator::getVulkanLicenseHeader() const +{ + return m_vulkanLicenseHeader; +} + +bool VulkanHppGenerator::isSubStruct(std::pair const& nsd, std::string const& name, StructData const& structData) +{ + if ((nsd.first != name) && (nsd.second.members.size() < structData.members.size()) && (structData.members[0].name != "sType")) + { + bool equal = true; + for (size_t i = 0; i < nsd.second.members.size() && equal; i++) + { + equal = (nsd.second.members[i].type == structData.members[i].type) && (nsd.second.members[i].name == structData.members[i].name); + } + if (equal) + { + return true; + } + } + return false; +} + +void VulkanHppGenerator::linkCommandToHandle(CommandData & commandData) +{ + // first, find the handle named like the type of the first argument + // if there is no such handle, look for the unnamed "handle", that gathers all the functions not tied to a specific handle + assert(!commandData.params.empty()); + std::map::iterator hit = m_handles.find(commandData.params[0].pureType); + if (hit == m_handles.end()) + { + hit = m_handles.find(""); + } + assert(hit != m_handles.end()); + + // put the command into the handle's list of commands, and store the handle in the commands className + hit->second.commands.push_back(commandData.fullName); + commandData.className = hit->first; + + // add the dependencies of the command to the dependencies of the handle + DependencyData const& commandDD = m_dependencies.back(); + std::list::iterator handleDD = std::find_if(m_dependencies.begin(), m_dependencies.end(), [hit](DependencyData const& dd) { return dd.name == hit->first; }); + assert((handleDD != m_dependencies.end()) || hit->first.empty()); + if (handleDD != m_dependencies.end()) + { + std::copy_if(commandDD.dependencies.begin(), commandDD.dependencies.end(), std::inserter(handleDD->dependencies, handleDD->dependencies.end()), [hit](std::string const& d) { return d != hit->first; }); + } +} + +bool VulkanHppGenerator::readCommandParam(tinyxml2::XMLElement const* element, std::set & dependencies, std::vector & params) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), {}, { { "externsync",{} },{ "len",{} },{ "noautovalidity",{ "true" } },{ "optional",{ "false", "true" } } }); + checkElements(getChildElements(element), { "name", "type" }); + + ParamData param; + + bool isTwoStep = false; + auto lenAttribute = attributes.find("len"); + if (lenAttribute != attributes.end()) + { + param.len = lenAttribute->second; + auto pit = std::find_if(params.begin(), params.end(), [¶m](ParamData const& pd) { return param.len == pd.name; }); + if (pit != params.end()) + { + isTwoStep = (pit->type.find('*') != std::string::npos); + } + } + + // get the type of the parameter, and put it into the list of dependencies + tinyxml2::XMLNode const* child = readCommandParamType(element->FirstChild(), param); + dependencies.insert(param.pureType); + + assert(child->ToElement()); + tinyxml2::XMLElement const* nameElement = child->ToElement(); + checkEmptyElement(nameElement); + param.name = child->ToElement()->GetText(); + + param.arraySize = readArraySize(child, param.name); + + auto optionalAttribute = attributes.find("optional"); + param.optional = (optionalAttribute != attributes.end()) && (optionalAttribute->second == "true"); + + params.push_back(param); + + assert(!isTwoStep || (param.type.substr(0, 6) != "const ")); + return isTwoStep; +} + +tinyxml2::XMLNode const* VulkanHppGenerator::readCommandParamType(tinyxml2::XMLNode const* node, ParamData& param) +{ + assert(node); + if (node->ToText()) + { + // start type with "const" or "struct", if needed + std::string value = trim(node->Value()); + assert((value == "const") || (value == "struct") || (value == "const struct")); + param.type = value + " "; + node = node->NextSibling(); + assert(node); + } + + // get the pure type + assert(node->ToElement()); + tinyxml2::XMLElement const* typeElement = node->ToElement(); + checkEmptyElement(typeElement); + std::string type = strip(node->ToElement()->GetText(), "Vk"); + param.unchangedType = param.type + node->ToElement()->GetText(); + param.type += type; + param.pureType = type; + + // end with "*", "**", or "* const*", if needed + node = node->NextSibling(); + assert(node); + if (node->ToText()) + { + std::string value = trimEnd(node->Value()); + assert((value == "*") || (value == "**") || (value == "* const*")); + param.type += value; + param.unchangedType += value; + node = node->NextSibling(); + } + + return node; +} + +void VulkanHppGenerator::readCommands(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), {}, { { "comment",{} } }); + std::vector children = getChildElements(element); + checkElements(children, { "command" }); + + for (auto child : children) + { + readCommandsCommand(child); + } +} + +void VulkanHppGenerator::readCommandsCommand(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), {}, + { { "alias", {} }, + { "cmdbufferlevel",{ "primary", "secondary" } }, + { "comment",{} }, + { "errorcodes",{} }, + { "name", {} }, + { "pipeline",{ "compute", "graphics", "transfer" } }, + { "queues",{ "compute", "graphics", "sparse_binding", "transfer" } }, + { "renderpass",{ "both", "inside", "outside" } }, + { "successcodes",{} } + }); + std::vector children = getChildElements(element); + + CommandData commandData; + auto aliasIt = attributes.find("alias"); + if (aliasIt != attributes.end()) + { + // for command aliases, create a copy of the aliased command + checkAttributes(attributes, element->GetLineNum(), { { "alias",{} },{ "name",{} } }, {}); // re-check on alias type! + checkElements(children, {}); + + std::string alias = startLowerCase(strip(aliasIt->second, "vk")); + checkAlias(m_commands, alias, element->GetLineNum()); + + auto commandsIt = m_commands.find(alias); + assert(commandsIt != m_commands.end()); + commandData = commandsIt->second; + commandData.fullName = startLowerCase(strip(attributes.find("name")->second, "vk")); + commandData.isAlias = true; + determineReducedName(commandData); + linkCommandToHandle(commandData); + + // add a DependencyData to this name + m_dependencies.push_back(DependencyData(DependencyData::Category::COMMAND, commandData.fullName)); + m_dependencies.back().dependencies.insert(alias); + } + else + { + checkElements(children, { "implicitexternsyncparams", "param", "proto" }); + + // read the success codes + auto successcodesAttribute = attributes.find("successcodes"); + if (successcodesAttribute != attributes.end()) + { + commandData.successCodes = tokenize(successcodesAttribute->second, ','); + for (auto & code : commandData.successCodes) + { + std::string tag = findTag(code, m_tags); + // on each success code: prepend 'e', strip "VK_" and a tag, convert it to camel case, and add the tag again + code = std::string("e") + toCamelCase(strip(code, "VK_", tag)) + tag; + } + } + + for (auto child : children) + { + std::string value = child->Value(); + if (value == "param") + { + commandData.twoStep |= readCommandParam(child, m_dependencies.back().dependencies, commandData.params); + } + else if (value == "proto") + { + readCommandProto(child, commandData.returnType, commandData.unchangedReturnType, commandData.fullName); + } +#if !defined(NDEBUG) + else + { + assert(value == "implicitexternsyncparams"); + skipImplicitExternSyncParams(child); + } +#endif + } + + determineReducedName(commandData); + linkCommandToHandle(commandData); + registerDeleter(commandData); + determineVectorParams(commandData); + determineReturnParam(commandData); + determineTemplateParam(commandData); + determineEnhancedReturnType(commandData); + determineSkippedParams(commandData); + } + + // insert the commandData into the commands-map, + assert(m_commands.find(commandData.fullName) == m_commands.end()); + m_commands.insert(std::make_pair(commandData.fullName, commandData)); +} + +void VulkanHppGenerator::readCommandProto(tinyxml2::XMLElement const* element, std::string & returnType, std::string & unchangedReturnType, std::string & fullName) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); + std::vector children = getChildElements(element); + checkOrderedElements(children, { "type", "name" }); + + // get return type and name of the command + returnType = strip(children[0]->GetText(), "Vk"); + unchangedReturnType = children[0]->GetText(); + fullName = startLowerCase(strip(children[1]->GetText(), "vk")); + + // add an empty DependencyData to this name + m_dependencies.push_back(DependencyData(DependencyData::Category::COMMAND, fullName)); +} + +void VulkanHppGenerator::readComment(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); + checkElements(getChildElements(element), {}); + + assert(element->GetText()); + std::string text = element->GetText(); + if (text.find("\nCopyright") == 0) + { + assert(m_vulkanLicenseHeader.empty()); + m_vulkanLicenseHeader = text; + + // erase the part after the Copyright text + size_t pos = m_vulkanLicenseHeader.find("\n\n------------------------------------------------------------------------"); + if (pos != std::string::npos) { + m_vulkanLicenseHeader.erase(pos); + } + + // replace any '\n' with "\n// " + for (pos = m_vulkanLicenseHeader.find('\n'); pos != std::string::npos; pos = m_vulkanLicenseHeader.find('\n', pos + 1)) + { + m_vulkanLicenseHeader.replace(pos, 1, "\n// "); + } + + // and add a little message on our own + m_vulkanLicenseHeader += "\n\n// This header is generated from the Khronos Vulkan XML API Registry."; + } + + m_vulkanLicenseHeader.erase(m_vulkanLicenseHeader.begin(), std::find_if(m_vulkanLicenseHeader.begin(), m_vulkanLicenseHeader.end(), [](char c) { return !std::isspace(c); })); +} + +void VulkanHppGenerator::readDisabledExtensionRequire(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), {}, {}); + std::vector children = getChildElements(element); + checkElements(children, { "command", "enum", "type" }); + + for (auto child : children) + { + checkElements(getChildElements(child), {}); + + std::string value = child->Value(); + if ((value == "command") || (value == "type")) + { + std::map attributes = getAttributes(child); + checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, {}); + + // disable a command or a type ! + auto nameAttribute = attributes.find("name"); + std::string name = (value == "command") ? startLowerCase(strip(nameAttribute->second, "vk")) : strip(nameAttribute->second, "Vk"); + + // search this name in the dependencies list and remove it + std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&name](DependencyData const& dd) { return(dd.name == name); }); + assert(depIt != m_dependencies.end()); + m_dependencies.erase(depIt); + + // erase it from all dependency sets + for (auto & dep : m_dependencies) + { + dep.dependencies.erase(name); + } + + if (value == "command") + { + // first unlink the command from its class + auto commandsIt = m_commands.find(name); + assert(commandsIt != m_commands.end()); + assert(!commandsIt->second.className.empty()); + auto handlesIt = m_handles.find(commandsIt->second.className); + assert(handlesIt != m_handles.end()); + auto it = std::find(handlesIt->second.commands.begin(), handlesIt->second.commands.end(), name); + assert(it != handlesIt->second.commands.end()); + handlesIt->second.commands.erase(it); + + // then remove the command + m_commands.erase(name); + } + else + { + // a type simply needs to be removed from the structs and vkTypes sets + assert((m_structs.find(name) != m_structs.end()) && (m_vkTypes.find(name) != m_vkTypes.end())); + m_structs.erase(name); + m_vkTypes.erase(name); + } + } + else + { + assert(value == "enum"); + std::map attributes = getAttributes(child); + checkAttributes(attributes, child->GetLineNum(), { { "name",{} } }, { { "bitpos", {} }, { "extends",{} },{ "offset",{} },{ "value",{} } }); + } + } +} + +void VulkanHppGenerator::readEnums(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { { "comment",{} },{ "type",{ "bitmask", "enum" } } }); + std::vector children = getChildElements(element); + checkElements(children, { "comment", "enum", "unused" }); + + std::string name = strip(attributes.find("name")->second, "Vk"); + + if (name == "API Constants") + { + for (auto child : children) + { + assert(strcmp(child->Value(), "enum") == 0); + readEnumsConstant(child); + } + } + else + { + checkAttributes(attributes, element->GetLineNum(), { { "name",{} },{ "type",{ "bitmask", "enum" } } }, { { "comment",{} } }); // re-check with type as required + + if (std::find_if(m_dependencies.begin(), m_dependencies.end(), [&name](DependencyData const& dd) { return dd.name == name; }) == m_dependencies.end()) + { + // add an empty DependencyData on this name into the dependencies list + m_dependencies.push_back(DependencyData(DependencyData::Category::ENUM, name)); + + // add this enum to the set of Vulkan data types + assert(m_vkTypes.find(name) == m_vkTypes.end()); + m_vkTypes.insert(name); + } + + // ad an empty EnumData on this name into the enums map + std::map::iterator it = m_enums.insert(std::make_pair(name, EnumData(name))).first; + assert(it->second.postfix.empty() && it->second.prefix.empty() && it->second.protect.empty() && it->second.values.empty()); + + if (name == "Result") + { + // special handling for VKResult, as its enums just have VK_ in common + it->second.prefix = "VK_"; + } + else + { + std::string type = attributes.find("type")->second; + it->second.bitmask = (type == "bitmask"); + if (it->second.bitmask) + { + // for a bitmask enum, start with "VK", cut off the trailing "FlagBits", and convert that name to upper case + // end that with "Bit" + size_t pos = name.find("FlagBits"); + assert(pos != std::string::npos); + it->second.prefix = "VK" + toUpperCase(name.substr(0, pos)) + "_"; + } + else + { + // for a non-bitmask enum, start with "VK", and convert the name to upper case + it->second.prefix = "VK" + toUpperCase(name) + "_"; + } + + // if the enum name contains a tag move it from the prefix to the postfix to generate correct enum value names. + for (std::set::const_iterator tit = m_tags.begin(); tit != m_tags.end(); ++tit) + { + if ((tit->length() < it->second.prefix.length()) && (it->second.prefix.substr(it->second.prefix.length() - tit->length() - 1) == (*tit + "_"))) + { + it->second.prefix.erase(it->second.prefix.length() - tit->length() - 1); + it->second.postfix = "_" + *tit; + break; + } + else if ((tit->length() < it->second.name.length()) && (it->second.name.substr(it->second.name.length() - tit->length()) == *tit)) + { + it->second.postfix = "_" + *tit; + break; + } + } + } + + // read the names of the enum values + for (auto child : children) + { + std::string value = child->Value(); + if (value == "enum") + { + readEnumsEnum(child, it->second, ""); + } +#if !defined(NDEBUG) + else + { + assert((value == "comment") || (value == "unused")); + } +#endif + } + } +} + +void VulkanHppGenerator::readEnumsEnum(tinyxml2::XMLElement const* element, EnumData & enumData, std::string const& tag) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { {"alias", {} }, { "bitpos",{} },{ "comment",{} },{ "value",{} } }); + assert((attributes.find("alias") != attributes.end()) + (attributes.find("bitpos") != attributes.end()) + (attributes.find("value") != attributes.end()) == 1); + checkElements(getChildElements(element), {}); + auto aliasIt = attributes.find("alias"); + if (aliasIt != attributes.end()) + { + auto enumIt = std::find_if(enumData.values.begin(), enumData.values.end(), [&aliasIt](EnumValueData const& evd) { return evd.value == aliasIt->second; }); + assert((enumIt != enumData.values.end()) && enumIt->alias.empty()); + enumIt->alias = createEnumValueName(attributes.find("name")->second, enumData.prefix, enumData.postfix, enumData.bitmask, tag); + } + else + { + enumData.addEnumValue(attributes.find("name")->second, tag, m_nameMap); + } +} + +void VulkanHppGenerator::readEnumsConstant(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { { "alias", {}}, { "comment",{} }, { "value",{} } }); + checkElements(getChildElements(element), {}); + std::string name = attributes.find("name")->second; + assert(m_constants.find(name) == m_constants.end()); + + auto aliasIt = attributes.find("alias"); + if (aliasIt != attributes.end()) + { + checkAttributes(attributes, element->GetLineNum(), { {"alias", {}}, { "name", {}} }, {}); // re-check on alias type + checkAlias(m_constants, aliasIt->second, element->GetLineNum()); + m_constants[name] = m_constants.find(aliasIt->second)->second; + } + else + { + checkAttributes(attributes, element->GetLineNum(), { { "name",{} }, { "value", {}} }, { {"comment", {} } }); // re-check on non-alias type + m_constants[name] = attributes.find("value")->second; + } +} + +void VulkanHppGenerator::readExtensionCommand(tinyxml2::XMLElement const* element, std::string const& protect) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, {}); + checkElements(getChildElements(element), {}); + + // just add the protect string to the CommandData + if (!protect.empty()) + { + std::string name = startLowerCase(strip(attributes.find("name")->second, "vk")); + std::map::iterator cit = m_commands.find(name); + assert(cit != m_commands.end()); + cit->second.protect = protect; + } +} + +void VulkanHppGenerator::readExtensionEnum(tinyxml2::XMLElement const* element, std::string const& tag) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), + { + { "name", {} } + }, + { + { "alias", {} }, + { "bitpos", {} }, + { "comment", {} }, + { "dir", { "-" } }, + { "extends", {} }, + { "extnumber", {} }, + { "offset", {} }, + { "value", {} } + }); + checkElements(getChildElements(element), {}); + + // TODO process enums which don't extend existing enums + auto extendsIt = attributes.find("extends"); + if (extendsIt != attributes.end()) + { + std::string extends = strip(extendsIt->second, "Vk"); + auto enumIt = m_enums.find(extends); + assert(enumIt != m_enums.end()); + + auto aliasIt = attributes.find("alias"); + if (aliasIt != attributes.end()) + { + checkAttributes(attributes, element->GetLineNum(), { { "alias", {} }, { "extends", {} }, { "name", {} } }, { { "comment",{} } }); + std::string alias = createEnumValueName(aliasIt->second, enumIt->second.prefix, enumIt->second.postfix, enumIt->second.bitmask, tag); + auto evdIt = std::find_if(enumIt->second.values.begin(), enumIt->second.values.end(), [&alias](EnumValueData const& evd) { return evd.name == alias; }); + assert(evdIt != enumIt->second.values.end()); + evdIt->alias = createEnumValueName(attributes.find("name")->second, enumIt->second.prefix, enumIt->second.postfix, enumIt->second.bitmask, tag); + if (evdIt->name == evdIt->alias) + { + // skip alias, that would result in the very same enum name + evdIt->alias.clear(); + } + } + else + { + assert((attributes.find("bitpos") != attributes.end()) + (attributes.find("offset") != attributes.end()) + (attributes.find("value") != attributes.end()) == 1); + enumIt->second.addEnumValue(attributes.find("name")->second, tag, m_nameMap); + } + } +} + +void VulkanHppGenerator::readExtensionRequire(tinyxml2::XMLElement const* element, std::string const& protect, std::string const& tag) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), {}, { { "extension",{} },{ "feature",{} } }); + std::vector children = getChildElements(element); + checkElements(children, { "command", "comment", "enum", "type" }); + + for (auto child : children) + { + std::string value = child->Value(); + + if (value == "command") + { + readExtensionCommand(child, protect); + } + else if (value == "enum") + { + readExtensionEnum(child, tag); + } + else if (value == "type") + { + readExtensionType(child, protect); + } +#if !defined(NDEBUG) + else + { + assert(value == "comment"); + checkEmptyElement(child); + } +#endif + } +} + +void VulkanHppGenerator::readExtensions(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "comment",{} } }, {}); + std::vector children = getChildElements(element); + checkElements(children, { "extension" }); + + for (auto child : children) + { + readExtensionsExtension(child); + } +} + +void VulkanHppGenerator::readExtensionsExtension(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), + { + { "name",{} }, + { "number",{} }, + { "supported",{ "disabled", "vulkan" } } + }, + { + { "author",{} }, + { "comment", {} }, + { "contact",{} }, + { "deprecatedby", {} }, + { "obsoletedby", {} }, + { "platform",{} }, + { "promotedto", {} }, + { "provisional", {} }, + { "protect",{} }, + { "requires",{} }, + { "requiresCore",{} }, + { "type",{ "device", "instance" } } + }); + std::vector children = getChildElements(element); + checkElements(children, { "require" }); + + if (attributes.find("supported")->second == "disabled") + { + // kick out all the disabled stuff we've read before !! + for (tinyxml2::XMLElement const* child = element->FirstChildElement(); child; child = child->NextSiblingElement()) + { + assert(strcmp(child->Value(), "require") == 0); + readDisabledExtensionRequire(child); + } + } + else + { + std::string name = attributes.find("name")->second; + std::string tag = extractTag(name); + assert(m_tags.find(tag) != m_tags.end()); + + auto protectAttribute = attributes.find("protect"); + auto platformAttribute = attributes.find("platform"); + std::string protect; + if (protectAttribute != attributes.end()) + { + protect = protectAttribute->second; + } + else if (platformAttribute != attributes.end()) + { + auto authorAttribute = attributes.find("author"); + assert(authorAttribute != attributes.end()); + protect = "VK_USE_PLATFORM_" + toUpperCase(platformAttribute->second) + "_" + authorAttribute->second; + } + +#if !defined(NDEBUG) + assert(m_extensions.find(name) == m_extensions.end()); + ExtensionData & extension = m_extensions.insert(std::make_pair(name, ExtensionData())).first->second; + extension.protect = protect; + auto requiresAttribute = attributes.find("requires"); + if (requiresAttribute != attributes.end()) + { + extension.requires = tokenize(requiresAttribute->second, ','); + } +#endif + + for (auto child : children) + { + readExtensionRequire(child, protect, tag); + } + } +} + +void VulkanHppGenerator::readExtensionType(tinyxml2::XMLElement const* element, std::string const& protect) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, {}); + checkElements(getChildElements(element), {}); + + // add the protect-string to the appropriate type: enum, flag, handle, scalar, or struct + if (!protect.empty()) + { + std::string name = strip(attributes.find("name")->second, "Vk"); + std::map::iterator bitmasksIt = m_bitmasks.find(name); + if (bitmasksIt != m_bitmasks.end()) + { + bitmasksIt->second.protect = protect; + + // if the enum of this flags is auto-generated, protect it as well + std::string enumName = generateEnumNameForFlags(name); + std::map::iterator enumsIt = m_enums.find(enumName); + assert(enumsIt != m_enums.end()); + if (enumsIt->second.values.empty()) + { + enumsIt->second.protect = protect; + } + } + else + { + std::map::iterator eit = m_enums.find(name); + if (eit != m_enums.end()) + { + eit->second.protect = protect; + } + else + { + std::map::iterator hait = m_handles.find(name); + if (hait != m_handles.end()) + { + hait->second.protect = protect; + } + else + { + std::map::iterator scit = m_scalars.find(name); + if (scit != m_scalars.end()) + { + scit->second.protect = protect; + } + else + { + std::map::iterator stit = m_structs.find(name); + if (stit != m_structs.end()) + { + stit->second.protect = protect; + } + else + { + assert(m_defines.find(name) != m_defines.end()); + } + } + } + } + } + } +} + +void VulkanHppGenerator::readFeature(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "api",{ "vulkan" } },{ "comment",{} },{ "name",{} },{ "number",{} } }, {}); + std::vector children = getChildElements(element); + checkElements(children, { "require" }); + + for (auto child : children) + { + readFeatureRequire(child); + } +} + +void VulkanHppGenerator::readFeatureRequire(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), {}, { { "comment",{} } }); + std::vector children = getChildElements(element); + checkElements(children, { "command", "comment", "enum", "type" }); + + for (auto child : children) + { + std::string value = child->Value(); + if (value == "enum") + { + readFeatureRequireEnum(child); + } +#if !defined(NDEBUG) + else + { + assert((value == "command") || (value == "comment") || (value == "type")); + skipFeatureRequire(child); + } +#endif + } +} + +void VulkanHppGenerator::readFeatureRequireEnum(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), + { + { "name",{} } + }, + { + { "bitpos",{} }, + { "comment",{} }, + { "dir", { "-" } }, + { "extends",{} }, + { "extnumber", {} }, + { "offset", {} }, + { "value",{} } + }); + checkElements(getChildElements(element), {}); + + auto extendsAttribute = attributes.find("extends"); + if (extendsAttribute != attributes.end()) + { + assert(strncmp(extendsAttribute->second.c_str(), "Vk", 2) == 0); + std::string extends = strip(extendsAttribute->second, "Vk"); + auto enumIt = m_enums.find(extends); + assert(enumIt != m_enums.end()); + enumIt->second.addEnumValue(attributes.find("name")->second, "", m_nameMap); + } +} + +void VulkanHppGenerator::readTags(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), { { "comment",{} } }, {}); + std::vector children = getChildElements(element); + checkElements(children, { "tag" }); + + for (auto child : children) + { + std::string value = child->Value(); + assert(value == "tag"); + readTag(child); + } +} + +void VulkanHppGenerator::readTag(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "author",{} },{ "contact",{} },{ "name",{} } }, {}); + checkElements(getChildElements(element), {}); + + for (auto const& attribute : attributes) + { + std::string name = attribute.first; + if (name == "name") + { + std::string value = attribute.second; + m_tags.insert(value); + } + else + { + assert((name == "author") || (name == "contact")); + } + } +} + +void VulkanHppGenerator::readType(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + + auto categoryIt = attributes.find("category"); + if (categoryIt != attributes.end()) + { + if (categoryIt->second == "basetype") + { + readTypeBasetype(element, attributes); + } + else if (categoryIt->second == "bitmask") + { + readTypeBitmask(element, attributes); + } + else if (categoryIt->second == "define") + { + readTypeDefine(element, attributes); + } + else if (categoryIt->second == "funcpointer") + { + readTypeFuncpointer(element, attributes); + } + else if (categoryIt->second == "handle") + { + readTypeHandle(element, attributes); + } + else if (categoryIt->second == "struct") + { + readTypeStruct(element, false, attributes); + } + else if (categoryIt->second == "union") + { + readTypeStruct(element, true, attributes); + } +#if !defined(NDEBUG) + else if (categoryIt->second == "enum") + { + skipTypeEnum(element, attributes); + } + else if (categoryIt->second == "include") + { + skipTypeInclude(element); + } + else +#else + else if ((categoryIt->second != "enum") && (categoryIt->second != "include")) +#endif + { + std::stringstream ss; + ss << element->GetLineNum(); + std::string lineNumber = ss.str(); + + throw std::runtime_error("Spec error on line " + lineNumber + ": unknown category <" + categoryIt->second + ">"); + } + } + else + { + assert(attributes.find("name") != attributes.end()); + readTypeName(element, attributes); + } +} + +void VulkanHppGenerator::readTypeBasetype(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { { "category",{ "basetype" } } }, {}); + std::vector children = getChildElements(element); + checkOrderedElements(children, { "type", "name" }); + checkEmptyElement(children[0]); + checkEmptyElement(children[1]); + + std::string type = children[0]->GetText(); + assert((type == "uint32_t") || (type == "uint64_t")); + + std::string name = strip(children[1]->GetText(), "Vk"); + + // skip "Flags", + if (name != "Flags") + { + m_dependencies.push_back(DependencyData(DependencyData::Category::SCALAR, name)); + m_dependencies.back().dependencies.insert(type); + } + else + { + assert(type == "uint32_t"); + } +} + +void VulkanHppGenerator::readTypeBitmask(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { { "category", { "bitmask" } } }, { { "alias", {} }, { "name", {}}, { "requires", {} } }); + std::vector children = getChildElements(element); + + auto aliasIt = attributes.find("alias"); + if (aliasIt != attributes.end()) + { + checkAttributes(attributes, element->GetLineNum(), { { "alias", {} }, { "category", {"bitmask"} }, { "name", {} } }, {}); // re-check on alias type! + checkElements(children, {}); + + std::string alias = strip(aliasIt->second, "Vk"); + checkAlias(m_bitmasks, alias, element->GetLineNum()); + + std::string name = strip(attributes.find("name")->second, "Vk"); + + auto bitmasksIt = m_bitmasks.find(alias); + assert((bitmasksIt != m_bitmasks.end()) && bitmasksIt->second.alias.empty()); + bitmasksIt->second.alias = name; + } + else + { + checkOrderedElements(children, { "type", "name" }); + checkEmptyElement(children[0]); + checkEmptyElement(children[1]); + + assert(strcmp(children[0]->GetText(), "VkFlags") == 0); + + std::string name = strip(children[1]->GetText(), "Vk"); + + std::string requires; + auto requiresIt = attributes.find("requires"); + if (requiresIt != attributes.end()) + { + requires = strip(requiresIt->second, "Vk"); + } + else + { + // Generate FlagBits name, add a DependencyData for that name, and add it to the list of enums and vulkan types + requires = generateEnumNameForFlags(name); + assert(std::find_if(m_dependencies.begin(), m_dependencies.end(), [&requires](DependencyData const& dd) { return dd.name == requires; }) == m_dependencies.end()); + m_dependencies.push_back(DependencyData(DependencyData::Category::ENUM, requires)); + assert(m_enums.find(requires) == m_enums.end()); + m_enums.insert(std::make_pair(requires, EnumData(requires, true))); + assert(m_vkTypes.find(requires) == m_vkTypes.end()); + m_vkTypes.insert(requires); + } + + // add a DependencyData for the bitmask name, with the required type as its first dependency + m_dependencies.push_back(DependencyData(DependencyData::Category::BITMASK, name)); + m_dependencies.back().dependencies.insert(requires); + + m_bitmasks.insert(std::make_pair(name, BitmaskData())); + + assert(m_vkTypes.find(name) == m_vkTypes.end()); + m_vkTypes.insert(name); + } +} + +void VulkanHppGenerator::readTypeDefine(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { { "category",{ "define" } } }, { { "name",{} } }); + + auto nameIt = attributes.find("name"); + if (nameIt != attributes.end()) + { + assert(!element->FirstChildElement()); + assert(nameIt->second == "VK_DEFINE_NON_DISPATCHABLE_HANDLE"); + + // filter out the check for the different types of VK_DEFINE_NON_DISPATCHABLE_HANDLE + std::string text = element->LastChild()->ToText()->Value(); + size_t start = text.find("#if defined(__LP64__)"); + size_t end = text.find_first_of("\r\n", start + 1); + m_typesafeCheck = text.substr(start, end - start); + } + else if (element->GetText() && (trim(element->GetText()) == "struct")) + { + tinyxml2::XMLElement const* child = element->FirstChildElement(); + assert(child && (strcmp(child->Value(), "name") == 0) && child->GetText()); + m_defines.insert(child->GetText()); + m_dependencies.push_back(DependencyData(DependencyData::Category::REQUIRED, child->GetText())); + } + else + { + tinyxml2::XMLElement const* child = element->FirstChildElement(); + assert(child && !child->FirstAttribute() && (strcmp(child->Value(), "name") == 0) && child->GetText()); + std::string text = trim(child->GetText()); + if (text == "VK_HEADER_VERSION") + { + m_version = trimEnd(element->LastChild()->ToText()->Value()); + } + // ignore all the other defines + assert(!child->NextSiblingElement() || (child->NextSiblingElement() && !child->NextSiblingElement()->FirstAttribute() && (strcmp(child->NextSiblingElement()->Value(), "type") == 0) && !child->NextSiblingElement()->NextSiblingElement())); + } +} + +void VulkanHppGenerator::readTypeFuncpointer(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { { "category",{ "funcpointer" } } }, { { "requires",{} } }); + std::vector children = getChildElements(element); + checkElements(children, { "name", "type" }); + assert(!children.empty()); + checkEmptyElement(children[0]); + + assert((strcmp(children[0]->Value(), "name") == 0) && children[0]->GetText()); + m_dependencies.push_back(DependencyData(DependencyData::Category::FUNC_POINTER, children[0]->GetText())); + +#if !defined(NDEBUG) + for (size_t i = 1; i < children.size(); i++) + { + checkEmptyElement(children[i]); + } +#endif +} + +void VulkanHppGenerator::readTypeHandle(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { { "category",{ "handle" } } }, { { "alias",{} }, { "name",{} }, { "parent",{} } }); + std::vector children = getChildElements(element); + + auto aliasIt = attributes.find("alias"); + if (aliasIt != attributes.end()) + { + checkAttributes(attributes, element->GetLineNum(), { { "alias",{} },{ "category",{ "handle" } },{ "name",{} } }, {}); // re-check on alias type! + checkElements(children, {}); + + std::string alias = strip(aliasIt->second, "Vk"); + checkAlias(m_handles, alias, element->GetLineNum()); + + std::string name = strip(attributes.find("name")->second, "Vk"); + + auto handlesIt = m_handles.find(alias); + assert((handlesIt != m_handles.end()) && handlesIt->second.alias.empty()); + handlesIt->second.alias = name; + } + else + { + checkOrderedElements(children, { "type", "name" }); + checkEmptyElement(children[0]); + checkEmptyElement(children[1]); + +#if !defined(NDEBUG) + std::string type = children[0]->GetText(); + assert((type.find("VK_DEFINE_HANDLE") == 0) || (type.find("VK_DEFINE_NON_DISPATCHABLE_HANDLE") == 0)); +#endif + + std::string name = strip(children[1]->GetText(), "Vk"); + + m_dependencies.push_back(DependencyData(DependencyData::Category::HANDLE, name)); + + assert(m_vkTypes.find(name) == m_vkTypes.end()); + m_vkTypes.insert(name); + assert(m_handles.find(name) == m_handles.end()); + m_handles.insert(std::make_pair(name, HandleData())); + } +} + +void VulkanHppGenerator::readTypeName(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { { "name",{} } }, { { "requires",{} } }); + checkElements(getChildElements(element), {}); + + auto nameIt = attributes.find("name"); + assert(nameIt != attributes.end()); + m_dependencies.push_back(DependencyData(DependencyData::Category::REQUIRED, nameIt->second)); +} + +void VulkanHppGenerator::readTypes(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), { { "comment",{} } }, {}); + std::vector children = getChildElements(element); + checkElements(children, { "comment", "type" }); + + for (auto child : children) + { + std::string value = child->Value(); + if (value == "type") + { + readType(child); + } +#if !defined(NDEBUG) + else + { + assert(value == "comment"); + checkEmptyElement(child); + } +#endif + } +} + +void VulkanHppGenerator::readTypeStruct(tinyxml2::XMLElement const* element, bool isUnion, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), + { + { "category",{ isUnion ? "union" : "struct" } }, + { "name",{} } + }, + { + { "alias", {} }, + { "comment",{} }, + { "returnedonly",{ "true" } }, + { "structextends",{} } + }); + std::vector children = getChildElements(element); + checkElements(children, { "comment", "member" }); + + std::string name = strip(attributes.find("name")->second, "Vk"); + + auto aliasIt = attributes.find("alias"); + if (aliasIt != attributes.end()) + { + checkAttributes(attributes, element->GetLineNum(), { { "alias", {}}, {"category", {"struct"}}, { "name", {}} }, {}); // re-check on alias type! + + std::string alias = strip(aliasIt->second, "Vk"); + checkAlias(m_structs, alias, element->GetLineNum()); + + auto structsIt = m_structs.find(alias); + assert((structsIt != m_structs.end()) && structsIt->second.alias.empty()); + structsIt->second.alias = name; + } + else + { + m_dependencies.push_back(DependencyData(isUnion ? DependencyData::Category::UNION : DependencyData::Category::STRUCT, name)); + + assert(m_structs.find(name) == m_structs.end()); + std::map::iterator it = m_structs.insert(std::make_pair(name, StructData())).first; + it->second.returnedOnly = (attributes.find("returnedonly") != attributes.end()); + it->second.isUnion = isUnion; + + auto attributesIt = attributes.find("structextends"); + if (attributesIt != attributes.end()) + { + std::vector structExtends = tokenize(attributesIt->second, ','); + for (auto const& s : structExtends) + { + assert(s.substr(0, 2) == "Vk"); + std::string strippedName = s.substr(2); + it->second.structExtends.push_back(strippedName); + m_extendedStructs.insert(strippedName); + } + assert(!it->second.structExtends.empty()); + } + + for (auto child : children) + { + assert(child->Value()); + std::string value = child->Value(); + if (value == "member") + { + readTypeStructMember(child, it->second); + } +#if !defined(NDEBUG) + else + { + assert(value == "comment"); + checkEmptyElement(child); + } +#endif + } + + for (auto const& s : m_structs) + { + if (isSubStruct(s, name, it->second)) + { + it->second.subStruct = s.first; + break; // just take the very first candidate as a subStruct, skip any possible others! + } + } + } + + assert(m_vkTypes.find(name) == m_vkTypes.end()); + m_vkTypes.insert(name); +} + +void VulkanHppGenerator::readTypeStructMember(tinyxml2::XMLElement const* element, StructData & structData) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), {}, + { + { "altlen",{} }, + { "externsync",{ "true" } }, + { "len",{} }, + { "noautovalidity",{ "true" } }, + { "optional",{ "false", "true" } }, + { "values",{} } + }); + std::vector children = getChildElements(element); + checkElements(children, { "comment", "enum", "name", "type" }); + for (auto child : children) + { + checkEmptyElement(child); + } + + structData.members.push_back(MemberData()); + MemberData & member = structData.members.back(); + + auto valuesAttribute = attributes.find("values"); + if (valuesAttribute != attributes.end()) + { + member.values = valuesAttribute->second; + } + + tinyxml2::XMLNode const* child = element->FirstChild(); + assert(child); + if (child->ToText()) + { + std::string value = trim(child->Value()); + assert((value == "const") || (value == "struct") || value == "const struct"); + member.type = value + " "; + child = child->NextSibling(); + assert(child); + } + + assert(child->ToElement()); + tinyxml2::XMLElement const* typeElement = child->ToElement(); + assert((strcmp(typeElement->Value(), "type") == 0) && typeElement->GetText()); + member.pureType = strip(typeElement->GetText(), "Vk"); + member.type += member.pureType; + + child = typeElement->NextSibling(); + assert(child); + if (child->ToText()) + { + std::string value = trimEnd(child->Value()); + assert((value == "*") || (value == "**") || (value == "* const*")); + member.type += value; + child = child->NextSibling(); + } + + m_dependencies.back().dependencies.insert(member.pureType); + + assert(child->ToElement()); + tinyxml2::XMLElement const* nameElement = child->ToElement(); + assert((strcmp(nameElement->Value(), "name") == 0) && nameElement->GetText()); + member.name = nameElement->GetText(); + + member.arraySize = readArraySize(nameElement, member.name); +} + +void VulkanHppGenerator::registerDeleter(CommandData const& commandData) +{ + if ((commandData.fullName.substr(0, 7) == "destroy") || (commandData.fullName.substr(0, 4) == "free")) + { + std::string key; + size_t valueIndex; + switch (commandData.params.size()) + { + case 2: + case 3: + assert(commandData.params.back().pureType == "AllocationCallbacks"); + key = (commandData.params.size() == 2) ? "" : commandData.params[0].pureType; + valueIndex = commandData.params.size() - 2; + break; + case 4: + key = commandData.params[0].pureType; + valueIndex = 3; + assert(m_deleters.find(commandData.params[valueIndex].pureType) == m_deleters.end()); + m_deleters[commandData.params[valueIndex].pureType].pool = commandData.params[1].pureType; + break; + default: + assert(false); + valueIndex = 0; + } + assert(m_deleterTypes[key].find(commandData.params[valueIndex].pureType) == m_deleterTypes[key].end()); + m_deleterTypes[key].insert(commandData.params[valueIndex].pureType); + m_deleters[commandData.params[valueIndex].pureType].call = commandData.reducedName; + } +} + +void VulkanHppGenerator::setDefault(std::string const& name, std::map & defaultValues, EnumData const& enumData) +{ + defaultValues[name] = name + (enumData.values.empty() ? "()" : ("::" + enumData.values.front().name)); +} + +void VulkanHppGenerator::sortDependencies() +{ + std::set listedTypes = { "VkFlags" }; + std::list sortedDependencies; + + while (!m_dependencies.empty()) + { + bool found = false; + for (std::list::iterator it = m_dependencies.begin(); it != m_dependencies.end(); ++it) + { + // check if all dependencies of it are already listed + if (std::find_if(it->dependencies.begin(), it->dependencies.end(), [&listedTypes](std::string const& d) { return listedTypes.find(d) == listedTypes.end(); }) == it->dependencies.end()) + { + // add it to the end of the sorted list and the set of listed types, remove it from the list of dependencies to handle and start over with the next dependency + sortedDependencies.push_back(*it); + listedTypes.insert(it->name); + + // if it is a struct, add any alias of it to the list of encountered types + if (it->category == DependencyData::Category::STRUCT) + { + std::map::const_iterator sit = m_structs.find(it->name); + assert(sit != m_structs.end()); + if (!sit->second.alias.empty()) + { + assert(listedTypes.find(sit->second.alias) == listedTypes.end()); + listedTypes.insert(sit->second.alias); + } + } + m_dependencies.erase(it); + found = true; + break; + } + } + if (!found) + { + // at least one dependency of it is not yet listed -> resolve direct circular dependencies + for (std::list::iterator it = m_dependencies.begin(); !found && it != m_dependencies.end(); ++it) + { + for (std::set::const_iterator dit = it->dependencies.begin(); dit != it->dependencies.end(); ++dit) + { + std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&dit](DependencyData const& dd) { return(dd.name == *dit); }); + if (depIt != m_dependencies.end()) + { + if (depIt->dependencies.find(it->name) != depIt->dependencies.end()) + { + // we only have two cases, for now! + assert((depIt->category == DependencyData::Category::STRUCT) && ((it->category == DependencyData::Category::HANDLE) || (it->category == DependencyData::Category::STRUCT))); + it->forwardDependencies.insert(*dit); + it->dependencies.erase(*dit); + found = true; + break; + } + } +#if !defined(NDEBUG) + else + { + // here, only already sorted dependencies should occur, or structs that are aliased and sorted + std::list::const_iterator sdit = std::find_if(sortedDependencies.begin(), sortedDependencies.end(), [&dit](DependencyData const& dd) { return(dd.name == *dit); }); + if (sdit == sortedDependencies.end()) + { + std::map::const_iterator sit = std::find_if(m_structs.begin(), m_structs.end(), [&dit](std::pair const& sd) { return sd.second.alias == *dit; }); + assert(sit != m_structs.end()); + assert(std::find_if(sortedDependencies.begin(), sortedDependencies.end(), [name = sit->first](DependencyData const& dd) { return dd.name == name; }) != sortedDependencies.end()); + } + } +#endif + } + } + } + assert(found); + } + + m_dependencies.swap(sortedDependencies); +} + +void VulkanHppGenerator::writeArguments(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular, size_t from, size_t to) +{ + assert(from <= to); + + // get the parameter indices of the counter for vector parameters + std::map countIndices; + for (std::map::const_iterator it = commandData.vectorParams.begin(); it != commandData.vectorParams.end(); ++it) + { + countIndices.insert(std::make_pair(it->second, it->first)); + } + + bool encounteredArgument = false; + for (size_t i = from; i < to; i++) + { + if (encounteredArgument) + { + os << ", "; + } + + std::map::const_iterator it = countIndices.find(i); + if (it != countIndices.end()) + { + writeCallCountParameter(os, commandData, singular, it); + } + else if ((it = commandData.vectorParams.find(i)) != commandData.vectorParams.end()) + { + writeCallVectorParameter(os, commandData, firstCall, singular, it); + } + else if (m_vkTypes.find(commandData.params[i].pureType) != m_vkTypes.end()) + { + writeCallVulkanTypeParameter(os, commandData.params[i]); + } + else + { + writeCallPlainTypeParameter(os, commandData.params[i]); + } + encounteredArgument = true; + } +} + +void VulkanHppGenerator::writeBitmaskToString(std::ostream & os, std::string const& bitmaskName, EnumData const &enumData) +{ + // the helper functions to make strings out of flag values + enterProtect(os, enumData.protect); + os << " VULKAN_HPP_INLINE std::string to_string(" << bitmaskName << (enumData.values.empty() ? ")" : " value)") << std::endl + << " {" << std::endl; + if (enumData.values.empty()) + { + // no flags values in this enum -> return "{}" + os << " return \"{}\";" << std::endl; + } + else + { + os << " if (!value) return \"{}\";" << std::endl + << " std::string result;" << std::endl; + + // 'or' together all the bits in the value + for (auto valuesIt = enumData.values.begin(); valuesIt != enumData.values.end(); ++valuesIt) + { + os << " if (value & " << enumData.name << "::" << valuesIt->name << ") result += \"" << valuesIt->name.substr(1) << " | \";" << std::endl; + } + // cut off the last three characters from the result (being " | ") + os << " return \"{\" + result.substr(0, result.size() - 3) + \"}\";" << std::endl; + } + os << " }" << std::endl; + leaveProtect(os, enumData.protect); + os << std::endl; +} + +void VulkanHppGenerator::writeCall(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular) +{ + // the original function call + os << "d.vk" << startUpperCase(commandData.fullName) << "( "; + + if (!commandData.className.empty()) + { + // if it's member of a class -> the first argument is the member variable, starting with "m_" + assert(commandData.className == commandData.params[0].type); + os << "m_" << startLowerCase(commandData.className); + if (1 < commandData.params.size()) + { + os << ", "; + } + } + + writeArguments(os, commandData, firstCall, singular, commandData.className.empty() ? 0 : 1, commandData.params.size()); + os << " )"; +} + +void VulkanHppGenerator::writeCallCountParameter(std::ostream & os, CommandData const& commandData, bool singular, std::map::const_iterator it) +{ + // this parameter is a count parameter for a vector parameter + if ((commandData.returnParam == it->second) && commandData.twoStep) + { + // the corresponding vector parameter is the return parameter and it's a two-step algorithm + // -> use the pointer to a local variable named like the counter parameter without leading 'p' + os << "&" << startLowerCase(strip(commandData.params[it->first].name, "p")); + } + else + { + // the corresponding vector parameter is not the return parameter, or it's not a two-step algorithm + if (singular) + { + // for the singular version, the count is just 1. + os << "1 "; + } + else + { + // for the non-singular version, the count is the size of the vector parameter + // -> use the vector parameter name without leading 'p' to get the size (in number of elements, not in bytes) + os << startLowerCase(strip(commandData.params[it->second].name, "p")) << ".size() "; + } + if (commandData.templateParam == it->second) + { + // if the vector parameter is templatized -> multiply by the size of that type to get the size in bytes + os << "* sizeof( T ) "; + } + } +} + +void VulkanHppGenerator::writeCallPlainTypeParameter(std::ostream & os, ParamData const& paramData) +{ + // this parameter is just a plain type + if (paramData.type.back() == '*') + { + // it's a pointer + std::string parameterName = startLowerCase(strip(paramData.name, "p")); + if (paramData.type.find("const") != std::string::npos) + { + // it's a const pointer + if (paramData.pureType == "char") + { + // it's a const pointer to char -> it's a string -> get the data via c_str() + os << parameterName; + if (paramData.optional) + { + // it's optional -> might use nullptr + os << " ? " << parameterName << "->c_str() : nullptr"; + } + else + { + os << ".c_str()"; + } + } + else + { + // it's const pointer to something else -> just use the name + assert(!paramData.optional); + os << paramData.name; + } + } + else + { + // it's a non-const pointer, and char is the only type that occurs -> use the address of the parameter + assert(paramData.type.find("char") == std::string::npos); + os << "&" << parameterName; + } + } + else + { + // it's a plain parameter -> just use its name + os << paramData.name; + } +} + +void VulkanHppGenerator::writeCallVectorParameter(std::ostream & os, CommandData const& commandData, bool firstCall, bool singular, std::map::const_iterator it) +{ + // this parameter is a vector parameter + assert(commandData.params[it->first].type.back() == '*'); + if ((commandData.returnParam == it->first) && commandData.twoStep && firstCall) + { + // this parameter is the return parameter, and it's the first call of a two-step algorithm -> just just nullptr + os << "nullptr"; + } + else + { + std::string parameterName = startLowerCase(strip(commandData.params[it->first].name, "p")); + std::set::const_iterator vkit = m_vkTypes.find(commandData.params[it->first].pureType); + if ((vkit != m_vkTypes.end()) || (it->first == commandData.templateParam)) + { + // CHECK for !commandData.params[it->first].optional + + // this parameter is a vulkan type or a templated type -> need to reinterpret cast + writeReinterpretCast(os, commandData.params[it->first].type.find("const") == 0, vkit != m_vkTypes.end(), commandData.params[it->first].pureType, commandData.params[it->first].type.rfind("* const") != std::string::npos); + os << "( "; + if (singular) + { + // in singular case, strip the plural-S from the name, and use the pointer to that thing + os << "&" << stripPluralS(parameterName); + } + else + { + // in plural case, get the pointer to the data + os << parameterName << ".data()"; + } + os << " )"; + } + else if (commandData.params[it->first].pureType == "char") + { + // the parameter is a vector to char -> it might be optional + // besides that, the parameter now is a std::string -> get the pointer via c_str() + os << parameterName; + if (commandData.params[it->first].optional) + { + os << " ? " << parameterName << "->c_str() : nullptr"; + } + else + { + os << ".c_str()"; + } + } + else + { + // this parameter is just a vetor -> get the pointer to its data + os << parameterName << ".data()"; + } + } +} + +void VulkanHppGenerator::writeCallVulkanTypeParameter(std::ostream & os, ParamData const& paramData) +{ + // this parameter is a vulkan type + if (paramData.type.back() == '*') + { + // it's a pointer -> needs a reinterpret cast to the vulkan type + std::string parameterName = startLowerCase(strip(paramData.name, "p")); + writeReinterpretCast(os, paramData.type.find("const") != std::string::npos, true, paramData.pureType, false); + os << "( "; + if (paramData.optional) + { + // for an optional parameter, we need also a static_cast from optional type to const-pointer to pure type + os << "static_cast( " << parameterName << " )"; + } + else + { + // other parameters can just use the pointer + os << "&" << parameterName; + } + os << " )"; + } + else + { + // a non-pointer parameter needs a static_cast from vk::-type to vulkan type + os << "static_cast( " << paramData.name << " )"; + } +} + +void VulkanHppGenerator::writeEnumsToString(std::ostream & os, EnumData const& enumData) +{ + // the helper functions to make strings out of enum values + enterProtect(os, enumData.protect); + os << " VULKAN_HPP_INLINE std::string to_string(" << enumData.name << (enumData.values.empty() ? ")" : " value)") << std::endl + << " {" << std::endl; + if (enumData.values.empty()) + { + // no enum values in this enum -> return "(void)" + os << " return \"(void)\";" << std::endl; + } + else + { + // otherwise switch over the value and return the a stringized version of that value (without leading 'e') + os << " switch (value)" << std::endl + << " {" << std::endl; + for (auto const& value : enumData.values) + { + os << " case " << enumData.name << "::" << value.name << ": return \"" << value.name.substr(1) << "\";" << std::endl; + } + os << " default: return \"invalid\";" << std::endl + << " }" << std::endl; + } + os << " }" << std::endl; + leaveProtect(os, enumData.protect); + os << std::endl; +} + +// Intended only for `enum class Result`! +void VulkanHppGenerator::writeExceptionsForEnum(std::ostream & os, EnumData const& enumData) +{ + std::string templateString = + R"( class ${className} : public SystemError + { + public: + ${className}( std::string const& message ) + : SystemError( make_error_code( ${enumName}::${enumMemberName} ), message ) {} + ${className}( char const * message ) + : SystemError( make_error_code( ${enumName}::${enumMemberName} ), message ) {} + }; +)"; + + enterProtect(os, enumData.protect); + for (size_t i = 0; i < enumData.values.size(); i++) + { + if (!isErrorEnum(enumData.values[i].name)) + { + continue; + } + os << replaceWithMap(templateString, + { { "className", stripErrorEnumPrefix(enumData.values[i].name) + "Error" }, + { "enumName", enumData.name }, + { "enumMemberName", enumData.values[i].name } + }); + } + leaveProtect(os, enumData.protect); + os << std::endl; +} + +void VulkanHppGenerator::writeFunction(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool definition, bool enhanced, bool singular, bool unique, bool isStructureChain) +{ + writeFunctionHeaderTemplate(os, indentation, commandData, enhanced, unique, !definition, isStructureChain); + + os << indentation << (definition ? "VULKAN_HPP_INLINE " : ""); + writeFunctionHeaderReturnType(os, commandData, enhanced, singular, unique, isStructureChain); + if (definition && !commandData.className.empty()) + { + os << commandData.className << "::"; + } + writeFunctionHeaderName(os, commandData.reducedName, singular, unique); + writeFunctionHeaderArguments(os, commandData, enhanced, singular, !definition); + os << (definition ? "" : ";") << std::endl; + + if (definition) + { + // write the function body + os << indentation << "{" << std::endl; + if (enhanced) + { + writeFunctionBodyEnhanced(os, indentation, commandData, singular, unique, isStructureChain); + } + else + { + writeFunctionBodyStandard(os, indentation, commandData); + } + os << indentation << "}" << std::endl; + } +} + +void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool singular, bool unique, bool isStructureChain) +{ + if (unique && !singular && (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end())) // returns a vector of UniqueStuff + { + std::string const stringTemplate = +R"(${i} static_assert( sizeof( ${type} ) <= sizeof( Unique${type} ), "${type} is greater than Unique${type}!" ); +${i} std::vector ${typeVariable}s; +${i} ${typeVariable}s.reserve( ${vectorSize} ); +${i} ${type}* buffer = reinterpret_cast<${type}*>( reinterpret_cast( ${typeVariable}s.data() ) + ${vectorSize} * ( sizeof( Unique${type} ) - sizeof( ${type} ) ) ); +${i} Result result = static_cast(d.vk${command}( m_device, ${arguments}, reinterpret_cast( buffer ) ) ); + +${i} ${Deleter}<${DeleterTemplate},Dispatch> deleter( *this, ${deleterArg}, d ); +${i} for ( size_t i=0 ; i<${vectorSize} ; i++ ) +${i} { +${i} ${typeVariable}s.push_back( Unique${type}( buffer[i], deleter ) ); +${i} } + +${i} return createResultValue( result, ${typeVariable}s, VULKAN_HPP_NAMESPACE_STRING "::${class}::${function}Unique" ); +)"; + + std::string type = (commandData.returnParam != INVALID_INDEX) ? commandData.params[commandData.returnParam].pureType : ""; + std::string typeVariable = startLowerCase(type); + std::ostringstream arguments; + writeArguments(arguments, commandData, true, singular, 1, commandData.params.size() - 1); + + std::map::const_iterator ddit = m_deleters.find(type); + assert(ddit != m_deleters.end()); + + bool isCreateFunction = (commandData.fullName.substr(0, 6) == "create"); + os << replaceWithMap(stringTemplate, std::map + { + { "i", indentation }, + { "type", type }, + { "typeVariable", typeVariable }, + { "vectorSize", isCreateFunction ? "createInfos.size()" : "allocateInfo." + typeVariable + "Count" }, + { "command", startUpperCase(commandData.fullName) }, + { "arguments", arguments.str() }, + { "Deleter", ddit->second.pool.empty() ? "ObjectDestroy" : "PoolFree" }, + { "DeleterTemplate", ddit->second.pool.empty() ? commandData.className : commandData.className + "," + ddit->second.pool }, + { "deleterArg", ddit->second.pool.empty() ? "allocator" : "allocateInfo." + startLowerCase(ddit->second.pool) }, + { "class", commandData.className }, + { "function", commandData.reducedName } + }); + } + else + { + if (1 < commandData.vectorParams.size()) + { + writeFunctionBodyEnhancedMultiVectorSizeCheck(os, indentation, commandData); + } + + std::string returnName; + if (commandData.returnParam != INVALID_INDEX) + { + returnName = writeFunctionBodyEnhancedLocalReturnVariable(os, indentation, commandData, singular, isStructureChain); + } + + if (commandData.twoStep) + { + assert(!singular); + writeFunctionBodyEnhancedLocalCountVariable(os, indentation, commandData); + + // we now might have to check the result, resize the returned vector accordingly, and call the function again + std::map::const_iterator returnit = commandData.vectorParams.find(commandData.returnParam); + assert(returnit != commandData.vectorParams.end() && (returnit->second != INVALID_INDEX)); + std::string sizeName = startLowerCase(strip(commandData.params[returnit->second].name, "p")); + + if (commandData.returnType == "Result") + { + if (1 < commandData.successCodes.size()) + { + writeFunctionBodyEnhancedCallTwoStepIterate(os, indentation, returnName, sizeName, commandData); + } + else + { + writeFunctionBodyEnhancedCallTwoStepChecked(os, indentation, returnName, sizeName, commandData); + } + } + else + { + writeFunctionBodyEnhancedCallTwoStep(os, indentation, returnName, sizeName, commandData); + } + } + else + { + if (commandData.returnType == "Result") + { + writeFunctionBodyEnhancedCallResult(os, indentation, commandData, singular); + } + else + { + writeFunctionBodyEnhancedCall(os, indentation, commandData, singular); + } + } + + if ((commandData.returnType == "Result") || !commandData.successCodes.empty()) + { + writeFunctionBodyEnhancedReturnResultValue(os, indentation, returnName, commandData, singular, unique); + } + else if ((commandData.returnParam != INVALID_INDEX) && (commandData.returnType != commandData.enhancedReturnType)) + { + // for the other returning cases, when the return type is somhow enhanced, just return the local returnVariable + os << indentation << " return " << returnName << ";" << std::endl; + } + } +} + +void VulkanHppGenerator::writeFunctionBodyEnhanced(std::ostream &os, std::string const& templateString, std::string const& indentation, CommandData const& commandData, bool singular) +{ + os << replaceWithMap(templateString, { + { "call", generateCall(commandData, true, singular) }, + { "i", indentation } + }); +} + +void VulkanHppGenerator::writeFunctionBodyTwoStep(std::ostream & os, std::string const &templateString, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) +{ + std::map replacements = { + { "sizeName", sizeName }, + { "returnName", returnName }, + { "call1", generateCall(commandData, true, false) }, + { "call2", generateCall(commandData, false, false) }, + { "i", indentation } + }; + + os << replaceWithMap(templateString, replacements); +} + +std::string VulkanHppGenerator::writeFunctionBodyEnhancedLocalReturnVariable(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool singular, bool isStructureChain) +{ + std::string returnName = startLowerCase(strip(commandData.params[commandData.returnParam].name, "p")); + + // there is a returned parameter -> we need a local variable to hold that value + if (commandData.returnType != commandData.enhancedReturnType) + { + // the returned parameter is somehow enhanced by us + os << indentation << " "; + if (singular) + { + if (isStructureChain) + { + std::string const &pureType = commandData.params[commandData.returnParam].pureType; + // For StructureChains use the template parameters + os << "StructureChain structureChain;" << std::endl; + returnName = stripPluralS(returnName); + os << indentation << " " << pureType << "& " << returnName << " = structureChain.template get<" << pureType << ">()"; + returnName = "structureChain"; + } + else + { + // in singular case, just use the return parameters pure type for the return variable + returnName = stripPluralS(returnName); + os << commandData.params[commandData.returnParam].pureType << " " << returnName; + } + } + else + { + // in non-singular case, use the enhanced type for the return variable (like vector<...>) + if (isStructureChain) + { + std::string const &returnType = commandData.enhancedReturnType; + // For StructureChains use the template parameters + os << "StructureChain structureChain;" << std::endl; + os << indentation << " " << returnType << "& " << returnName << " = structureChain.template get<" << returnType << ">()"; + returnName = "structureChain"; + } + else + { + os << commandData.enhancedReturnType << " " << returnName; + } + + std::map::const_iterator it = commandData.vectorParams.find(commandData.returnParam); + if (it != commandData.vectorParams.end() && !commandData.twoStep) + { + // if the return parameter is a vector parameter, and not part of a two-step algorithm, initialize its size + std::string size; + if (it->second == INVALID_INDEX) + { + assert(!commandData.params[commandData.returnParam].len.empty()); + // the size of the vector is not given by an other parameter, but by some member of a parameter, described as 'parameter::member' + // -> replace the '::' by '.' and filter out the leading 'p' to access that value + size = startLowerCase(strip(commandData.params[commandData.returnParam].len, "p")); + size_t pos = size.find("::"); + assert(pos != std::string::npos); + size.replace(pos, 2, "."); + } + else + { + // the size of the vector is given by an other parameter + // first check, if that size has become the size of some other vector parameter + // -> look for it and get it's actual size + for (auto const& vectorParam : commandData.vectorParams) + { + if ((vectorParam.first != it->first) && (vectorParam.second == it->second)) + { + size = startLowerCase(strip(commandData.params[vectorParam.first].name, "p")) + ".size()"; + break; + } + } + if (size.empty()) + { + // otherwise, just use that parameter + size = commandData.params[it->second].name; + } + } + assert(!size.empty()); + os << "( " << size << " )"; + } + } + os << ";" << std::endl; + } + else + { + // the return parameter is not enhanced -> the type is supposed to be a Result and there are more than one success codes! + assert((commandData.returnType == "Result") && (1 < commandData.successCodes.size())); + os << indentation << " " << commandData.params[commandData.returnParam].pureType << " " << returnName << ";" << std::endl; + } + + return returnName; +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedCall(std::ostream &os, std::string const& indentation, CommandData const& commandData, bool singular) +{ + std::string const templateString = "${i} return ${call};\n"; + std::string const templateStringVoid = "${i} ${call};\n"; + writeFunctionBodyEnhanced(os, commandData.returnType == "void" ? templateStringVoid : templateString, indentation, commandData, singular); +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedCallResult(std::ostream &os, std::string const& indentation, CommandData const& commandData, bool singular) +{ + std::string const templateString = "${i} Result result = static_cast( ${call} );\n"; + writeFunctionBodyEnhanced(os, templateString, indentation, commandData, singular); +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedCallTwoStep(std::ostream & os, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) +{ + std::string const templateString = + R"(${i} ${call1}; +${i} ${returnName}.resize( ${sizeName} ); +${i} ${call2}; +)"; + writeFunctionBodyTwoStep(os, templateString, indentation, returnName, sizeName, commandData); +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedCallTwoStepIterate(std::ostream & os, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) +{ + std::string const templateString = + R"(${i} Result result; +${i} do +${i} { +${i} result = static_cast( ${call1} ); +${i} if ( ( result == Result::eSuccess ) && ${sizeName} ) +${i} { +${i} ${returnName}.resize( ${sizeName} ); +${i} result = static_cast( ${call2} ); +${i} } +${i} } while ( result == Result::eIncomplete ); +${i} VULKAN_HPP_ASSERT( ${sizeName} <= ${returnName}.size() ); +${i} ${returnName}.resize( ${sizeName} ); +)"; + writeFunctionBodyTwoStep(os, templateString, indentation, returnName, sizeName, commandData); +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedCallTwoStepChecked(std::ostream & os, std::string const& indentation, std::string const& returnName, std::string const& sizeName, CommandData const& commandData) +{ + std::string const templateString = + R"(${i} Result result = static_cast( ${call1} ); +${i} if ( ( result == Result::eSuccess ) && ${sizeName} ) +${i} { +${i} ${returnName}.resize( ${sizeName} ); +${i} result = static_cast( ${call2} ); +${i} } +)"; + writeFunctionBodyTwoStep(os, templateString, indentation, returnName, sizeName, commandData); +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedLocalCountVariable(std::ostream & os, std::string const& indentation, CommandData const& commandData) +{ + // local count variable to hold the size of the vector to fill + assert(commandData.returnParam != INVALID_INDEX); + + std::map::const_iterator returnit = commandData.vectorParams.find(commandData.returnParam); + assert(returnit != commandData.vectorParams.end() && (returnit->second != INVALID_INDEX)); + assert((commandData.returnType == "Result") || (commandData.returnType == "void")); + + // take the pure type of the size parameter; strip the leading 'p' from its name for its local name + os << indentation << " " << commandData.params[returnit->second].pureType << " " << startLowerCase(strip(commandData.params[returnit->second].name, "p")) << ";" << std::endl; +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedMultiVectorSizeCheck(std::ostream & os, std::string const& indentation, CommandData const& commandData) +{ + std::string const templateString = + R"#(#ifdef VULKAN_HPP_NO_EXCEPTIONS +${i} VULKAN_HPP_ASSERT( ${firstVectorName}.size() == ${secondVectorName}.size() ); +#else +${i} if ( ${firstVectorName}.size() != ${secondVectorName}.size() ) +${i} { +${i} throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${reducedName}: ${firstVectorName}.size() != ${secondVectorName}.size()" ); +${i} } +#endif // VULKAN_HPP_NO_EXCEPTIONS +)#"; + + + // add some error checks if multiple vectors need to have the same size + for (std::map::const_iterator it0 = commandData.vectorParams.begin(); it0 != commandData.vectorParams.end(); ++it0) + { + if (it0->first != commandData.returnParam) + { + for (std::map::const_iterator it1 = std::next(it0); it1 != commandData.vectorParams.end(); ++it1) + { + if ((it1->first != commandData.returnParam) && (it0->second == it1->second)) + { + os << replaceWithMap(templateString, std::map({ + { "firstVectorName", startLowerCase(strip(commandData.params[it0->first].name, "p")) }, + { "secondVectorName", startLowerCase(strip(commandData.params[it1->first].name, "p")) }, + { "className", commandData.className }, + { "reducedName", commandData.reducedName }, + { "i", indentation } + })); + } + } + } + } +} + +void VulkanHppGenerator::writeFunctionBodyEnhancedReturnResultValue(std::ostream & os, std::string const& indentation, std::string const& returnName, CommandData const& commandData, bool singular, bool unique) +{ + std::string type = (commandData.returnParam != INVALID_INDEX) ? commandData.params[commandData.returnParam].pureType : ""; + std::string returnVectorName = (commandData.returnParam != INVALID_INDEX) ? strip(commandData.params[commandData.returnParam].name, "p", "s") : ""; + + if (unique) + { + // the unique version needs a Deleter object for destruction of the newly created stuff + // get the DeleterData corresponding to the returned type + std::map::const_iterator ddit = m_deleters.find(type); + assert(ddit != m_deleters.end() && ddit->second.pool.empty()); + + // special handling for "createDevice", as Device is created from PhysicalDevice, but destroyed on its own + bool noParent = commandData.className.empty() || (commandData.fullName == "createDevice"); + os << std::endl + << indentation << ((commandData.fullName == "allocateMemory") ? " ObjectFree<" : " ObjectDestroy<") << (noParent ? "NoParent" : commandData.className) << ",Dispatch> deleter( " << (noParent ? "" : "*this, ") << "allocator, d );" << std::endl + << indentation << " return createResultValue<" << type << ",Dispatch>( result, "; + } + else + { + os << indentation << " return createResultValue( result, "; + } + + // if the return type is "Result" or there is at least one success code, create the Result/Value construct to return + if (commandData.returnParam != INVALID_INDEX) + { + // if there's a return parameter, list it in the Result/Value constructor + os << returnName << ", "; + } + + // now the function name (with full namespace) as a string + os << "VULKAN_HPP_NAMESPACE_STRING\"::" << (commandData.className.empty() ? "" : commandData.className + "::") << (singular ? stripPluralS(commandData.reducedName) : commandData.reducedName) << (unique ? "Unique" : "") << "\""; + + if (!commandData.twoStep && (1 < commandData.successCodes.size())) + { + // and for the single-step algorithms with more than one success code list them all + os << ", { Result::" << commandData.successCodes[0]; + for (size_t i = 1; i < commandData.successCodes.size(); i++) + { + os << ", Result::" << commandData.successCodes[i]; + } + os << " }"; + } + + if (unique) + { + os << ", deleter"; + } + + os << " );" << std::endl; +} + +void VulkanHppGenerator::writeFunctionBodyStandard(std::ostream & os, std::string const& indentation, CommandData const& commandData) +{ + os << indentation << " "; + bool castReturn = false; + if (commandData.returnType != "void") + { + // there's something to return... + os << "return "; + + castReturn = (m_vkTypes.find(commandData.returnType) != m_vkTypes.end()); + if (castReturn) + { + // the return-type is a vulkan type -> need to cast to vk::-type + os << "static_cast<" << commandData.returnType << ">( "; + } + } + + // call the original function + os << "d.vk" << startUpperCase(commandData.fullName) << "( "; + + if (!commandData.className.empty()) + { + // the command is part of a class -> the first argument is the member variable, starting with "m_" + assert(commandData.className == commandData.params[0].type); + os << "m_" << startLowerCase(commandData.className); + } + + // list all the arguments + for (size_t i = commandData.className.empty() ? 0 : 1; i < commandData.params.size(); i++) + { + if (0 < i) + { + os << ", "; + } + + if (m_vkTypes.find(commandData.params[i].pureType) != m_vkTypes.end()) + { + // the parameter is a vulkan type + if (commandData.params[i].type.back() == '*') + { + // it's a pointer -> need to reinterpret_cast it + writeReinterpretCast(os, commandData.params[i].type.find("const") == 0, true, commandData.params[i].pureType, commandData.params[i].type.find("* const") != std::string::npos); + } + else + { + // it's a value -> need to static_cast ist + os << "static_cast"; + } + os << "( " << commandData.params[i].name << " )"; + } + else + { + // it's a non-vulkan type -> just use it + os << commandData.params[i].name; + } + } + os << " )"; + + if (castReturn) + { + // if we cast the return -> close the static_cast + os << " )"; + } + os << ";" << std::endl; +} + +void VulkanHppGenerator::writeFunctionHeaderArguments(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool withDefaults) +{ + os << "("; + if (enhanced) + { + writeFunctionHeaderArgumentsEnhanced(os, commandData, singular, withDefaults); + } + else + { + writeFunctionHeaderArgumentsStandard(os, commandData, withDefaults); + } + os << ")"; + if (!commandData.className.empty()) + { + os << " const"; + } +} + +void VulkanHppGenerator::writeFunctionHeaderArgumentsEnhanced(std::ostream & os, CommandData const& commandData, bool singular, bool withDefaults) +{ + // check if there's at least one argument left to put in here + if (commandData.skippedParams.size() + (commandData.className.empty() ? 0 : 1) < commandData.params.size()) + { + // determine the last argument, where we might provide some default for + size_t lastArgument = INVALID_INDEX; + for (size_t i = commandData.params.size() - 1; i < commandData.params.size(); i--) + { + if (commandData.skippedParams.find(i) == commandData.skippedParams.end()) + { + lastArgument = i; + break; + } + } + + os << " "; + bool argEncountered = false; + for (size_t i = commandData.className.empty() ? 0 : 1; i < commandData.params.size(); i++) + { + if (commandData.skippedParams.find(i) == commandData.skippedParams.end()) + { + if (argEncountered) + { + os << ", "; + } + std::string strippedParameterName = startLowerCase(strip(commandData.params[i].name, "p")); + + std::map::const_iterator it = commandData.vectorParams.find(i); + size_t rightStarPos = commandData.params[i].type.rfind('*'); + if (it == commandData.vectorParams.end()) + { + // the argument ist not a vector + if (rightStarPos == std::string::npos) + { + // and its not a pointer -> just use its type and name here + os << commandData.params[i].type << " " << commandData.params[i].name; + if (!commandData.params[i].arraySize.empty()) + { + os << "[" << commandData.params[i].arraySize << "]"; + } + + if (withDefaults && (lastArgument == i)) + { + // check if the very last argument is a flag without any bits -> provide some empty default for it + std::map::const_iterator bitmasksIt = m_bitmasks.find(commandData.params[i].pureType); + if (bitmasksIt != m_bitmasks.end()) + { + // get the enum corresponding to this flag, to check if it's empty + std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&bitmasksIt](DependencyData const& dd) { return(dd.name == bitmasksIt->first); }); + assert((depIt != m_dependencies.end()) && (depIt->dependencies.size() == 1)); + std::map::const_iterator enumIt = m_enums.find(*depIt->dependencies.begin()); + assert(enumIt != m_enums.end()); + if (enumIt->second.values.empty()) + { + // there are no bits in this flag -> provide the default + os << " = " << commandData.params[i].pureType << "()"; + } + } + } + } + else + { + // the argument is not a vector, but a pointer + assert(commandData.params[i].type[rightStarPos] == '*'); + if (commandData.params[i].optional) + { + // for an optional argument, trim the trailing '*' from the type, and the leading 'p' from the name + os << "Optional<" << trimEnd(commandData.params[i].type.substr(0, rightStarPos)) << "> " << strippedParameterName; + if (withDefaults) + { + os << " = nullptr"; + } + } + else if (commandData.params[i].pureType == "void") + { + // for void-pointer, just use type and name + os << commandData.params[i].type << " " << commandData.params[i].name; + } + else if (commandData.params[i].pureType != "char") + { + // for non-char-pointer, change to reference + os << trimEnd(commandData.params[i].type.substr(0, rightStarPos)) << " & " << strippedParameterName; + } + else + { + // for char-pointer, change to const reference to std::string + os << "const std::string & " << strippedParameterName; + } + } + } + else + { + // the argument is a vector + // it's optional, if it's marked as optional and there's no size specified + bool optional = commandData.params[i].optional && (it->second == INVALID_INDEX); + assert((rightStarPos != std::string::npos) && (commandData.params[i].type[rightStarPos] == '*')); + if (commandData.params[i].type.find("char") != std::string::npos) + { + // it's a char-vector -> use a std::string (either optional or a const-reference + if (optional) + { + os << "Optional " << strippedParameterName; + if (withDefaults) + { + os << " = nullptr"; + } + } + else + { + os << "const std::string & " << strippedParameterName; + } + } + else + { + // it's a non-char vector (they are never optional) + assert(!optional); + if (singular) + { + // in singular case, change from pointer to reference + os << trimEnd(commandData.params[i].type.substr(0, rightStarPos)) << " & " << stripPluralS(strippedParameterName); + } + else + { + // otherwise, use our ArrayProxy + bool isConst = (commandData.params[i].type.find("const") != std::string::npos); + os << "ArrayProxy<" << ((commandData.templateParam == i) ? (isConst ? "const T" : "T") : trimEnd(commandData.params[i].type.substr(0, rightStarPos))) << "> " << strippedParameterName; + } + } + } + argEncountered = true; + } + } + + if (argEncountered) + { + os << ", "; + } + } + os << "Dispatch const &d"; + if (withDefaults) + { + os << " = Dispatch()"; + } + + os << " "; +} + +void VulkanHppGenerator::writeFunctionHeaderArgumentsStandard(std::ostream & os, CommandData const& commandData, bool withDefaults) +{ + // for the standard case, just list all the arguments as we've got them + bool argEncountered = false; + + // determine the last argument, where we might provide some default for + size_t lastArgument = commandData.params.size() - 1; + + for (size_t i = commandData.className.empty() ? 0 : 1; i < commandData.params.size(); i++) + { + if (argEncountered) + { + os << ","; + } + + os << " " << commandData.params[i].type << " " << commandData.params[i].name; + if (!commandData.params[i].arraySize.empty()) + { + os << "[" << commandData.params[i].arraySize << "]"; + } + + if (withDefaults && (lastArgument == i)) + { + // check if the very last argument is a flag without any bits -> provide some empty default for it + std::map::const_iterator flagIt = m_bitmasks.find(commandData.params[i].pureType); + if (flagIt != m_bitmasks.end()) + { + // get the enum corresponding to this flag, to check if it's empty + std::list::const_iterator depIt = std::find_if(m_dependencies.begin(), m_dependencies.end(), [&flagIt](DependencyData const& dd) { return(dd.name == flagIt->first); }); + assert((depIt != m_dependencies.end()) && (depIt->dependencies.size() == 1)); + std::map::const_iterator enumIt = m_enums.find(*depIt->dependencies.begin()); + assert(enumIt != m_enums.end()); + if (enumIt->second.values.empty()) + { + // there are no bits in this flag -> provide the default + os << " = " << commandData.params[i].pureType << "()"; + } + } + } + argEncountered = true; + } + if (argEncountered) + { + os << ", "; + } + + os << "Dispatch const &d"; + if (withDefaults) + { + os << " = Dispatch() "; + } +} + +void VulkanHppGenerator::writeFunctionHeaderReturnType(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain) +{ + std::string templateString; + std::string returnType; + if (enhanced) + { + // the enhanced function might return some pretty complex return stuff + if (isStructureChain || (!singular && (commandData.enhancedReturnType.find("Allocator") != std::string::npos))) + { + // for the non-singular case with allocation, we need to prepend with 'typename' to keep compilers happy + templateString = "typename "; + } + if (unique) + { + // the unique version returns something prefixed with 'Unique'; potentially a vector of that stuff + // it's a vector, if it's not the singular version and the return parameter is a vector parameter + bool returnsVector = !singular && (commandData.vectorParams.find(commandData.returnParam) != commandData.vectorParams.end()); + + templateString += returnsVector ? "ResultValueType,Allocator>>::type " : "typename ResultValueType>::type "; + returnType = isStructureChain ? "StructureChain" : commandData.params[commandData.returnParam].pureType; + } + else if ((commandData.enhancedReturnType != commandData.returnType) && (commandData.returnType != "void")) + { + // if the enhanced return type differs from the original return type, and it's not void, we return a ResultValueType<...>::type + templateString += "ResultValueType<${returnType}>::type "; + + assert(commandData.returnType == "Result"); + // in singular case, we create the ResultValueType from the pure return type, otherwise from the enhanced return type + if (isStructureChain) + { + returnType = "StructureChain"; + } + else + { + returnType = singular ? commandData.params[commandData.returnParam].pureType : commandData.enhancedReturnType; + } + } + else if ((commandData.returnParam != INVALID_INDEX) && (1 < commandData.successCodes.size())) + { + // if there is a return parameter at all, and there are multiple success codes, we return a ResultValue<...> with the pure return type + assert(commandData.returnType == "Result"); + templateString = "ResultValue<${returnType}> "; + returnType = isStructureChain ? "StructureChain" : commandData.params[commandData.returnParam].pureType; + } + else + { + // and in every other case, we just return the enhanced return type. + templateString = "${returnType} "; + returnType = isStructureChain ? "StructureChain" : commandData.enhancedReturnType; + } + } + else + { + // the non-enhanced function just uses the return type + templateString = "${returnType} "; + returnType = commandData.returnType; + } + os << replaceWithMap(templateString, { { "returnType", returnType } }); +} + +void VulkanHppGenerator::writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool unique, bool withDefault, bool isStructureChain) +{ + std::string dispatch = withDefault ? std::string("typename Dispatch = DispatchLoaderStatic") : std::string("typename Dispatch"); + if (enhanced && isStructureChain) + { + os << indentation << "template " << std::endl; + } + else if (enhanced && (commandData.templateParam != INVALID_INDEX) && ((commandData.templateParam != commandData.returnParam) || (commandData.enhancedReturnType == "Result"))) + { + // if there's a template parameter, not being the return parameter or where the enhanced return type is 'Result' -> templatize on type 'T' + assert(commandData.enhancedReturnType.find("Allocator") == std::string::npos); + os << indentation << "template " << std::endl; + } + else if (enhanced && (commandData.enhancedReturnType.find("Allocator") != std::string::npos)) + { + // otherwise, if there's an Allocator used in the enhanced return type, we templatize on that Allocator + assert((commandData.enhancedReturnType.substr(0, 12) == "std::vector<") && (commandData.enhancedReturnType.find(',') != std::string::npos) && (12 < commandData.enhancedReturnType.find(','))); + os << indentation << "template ' + os << " = std::allocator<" << (unique ? "Unique" : "") << commandData.enhancedReturnType.substr(12, commandData.enhancedReturnType.find(',') - 12) << ">"; + } + os << ", " << dispatch; + os << "> " << std::endl; + } + else + { + os << indentation << "template<" << dispatch << ">" << std::endl; + } +} + +void VulkanHppGenerator::writeResultEnum(std::ostream & os) +{ + std::list::const_iterator it = std::find_if(m_dependencies.begin(), m_dependencies.end(), [](DependencyData const& dp) { return dp.name == "Result"; }); + assert(it != m_dependencies.end()); + writeTypeEnum(os, m_enums.find(it->name)->second); + writeEnumsToString(os, m_enums.find(it->name)->second); + os << "#ifndef VULKAN_HPP_NO_EXCEPTIONS"; + os << exceptionHeader; + os << exceptionClassesHeader; + writeExceptionsForEnum(os, m_enums.find(it->name)->second); + writeThrowExceptions(os, m_enums.find(it->name)->second); + os << "#endif" << std::endl; + m_dependencies.erase(it); +} + +void VulkanHppGenerator::writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map const& defaultValues) +{ + // the constructor with all the elements as arguments, with defaults + std::string ctorOpening = " " + name + "( "; + size_t indentSize = ctorOpening.size(); + os << ctorOpening; + + bool listedArgument = false; + for (size_t i = 0; i < structData.members.size(); i++) + { + listedArgument = writeStructConstructorArgument(os, listedArgument, indentSize, structData.members[i], defaultValues); + } + os << " )" << std::endl; + + // copy over the simple arguments + bool firstArgument = true; + for (size_t i = 0; i < structData.members.size(); i++) + { + // skip members 'pNext' and 'sType' are directly set by initializers + if ((structData.members[i].name != "pNext") && (structData.members[i].name != "sType") && (structData.members[i].arraySize.empty())) + { + // here, we can only handle non-array arguments + std::string templateString = " ${sep} ${member}( ${value} )\n"; + std::string sep = firstArgument ? ":" : ","; + std::string member = structData.members[i].name; + std::string value = structData.members[i].name + "_"; // the elements are initialized by the corresponding argument (with trailing '_', as mentioned above) + + os << replaceWithMap(templateString, { { "sep", sep },{ "member", member },{ "value", value } }); + firstArgument = false; + } + } + + // the body of the constructor, copying over data from argument list into wrapped struct + os << " {" << std::endl; + for (size_t i = 0; i < structData.members.size(); i++) + { + if (!structData.members[i].arraySize.empty()) + { + // here we can handle the arrays, copying over from argument (with trailing '_') to member + // size is arraySize times sizeof type + std::string member = structData.members[i].name; + std::string arraySize = structData.members[i].arraySize; + std::string type = structData.members[i].type; + os << replaceWithMap(" memcpy( &${member}, ${member}_.data(), ${arraySize} * sizeof( ${type} ) );\n", + { { "member", member },{ "arraySize", arraySize },{ "type", type } }); + } + } + os << " }\n\n"; + + if (!structData.subStruct.empty()) + { + auto const& subStruct = m_structs.find(structData.subStruct); + assert(subStruct != m_structs.end()); + + std::string subStructArgumentName = startLowerCase(strip(subStruct->first, "vk")); + ctorOpening = " explicit " + name + "( "; + indentSize = ctorOpening.size(); + + os << ctorOpening << subStruct->first << " const& " << subStructArgumentName; + + for (size_t i = subStruct->second.members.size(); i < structData.members.size(); i++) + { + writeStructConstructorArgument(os, true, indentSize, structData.members[i], defaultValues); + } + os << " )" << std::endl; + + firstArgument = true; + std::string templateString = " ${sep} ${member}( ${value} )\n"; + for (size_t i = 0; i < subStruct->second.members.size(); i++) + { + assert(structData.members[i].arraySize.empty()); + std::string sep = firstArgument ? ":" : ","; + std::string member = structData.members[i].name; + std::string value = subStructArgumentName + "." + subStruct->second.members[i].name; + + os << replaceWithMap(templateString, { { "sep", sep },{ "member", member },{ "value", value } }); + firstArgument = false; + } + for (size_t i = subStruct->second.members.size(); i < structData.members.size(); i++) + { + assert(structData.members[i].arraySize.empty()); + std::string member = structData.members[i].name; + std::string value = structData.members[i].name + "_"; // the elements are initialized by the corresponding argument (with trailing '_', as mentioned above) + + os << replaceWithMap(templateString, { { "sep", "," },{ "member", member },{ "value", value } }); + } + os << " {}" << std::endl << std::endl; + } + + std::string templateString = + R"( ${name}( Vk${name} const & rhs ) + { + memcpy( this, &rhs, sizeof( ${name} ) ); + } + + ${name}& operator=( Vk${name} const & rhs ) + { + memcpy( this, &rhs, sizeof( ${name} ) ); + return *this; + } +)"; + + os << replaceWithMap(templateString, { { "name", name } }); +} + +void VulkanHppGenerator::writeIndentation(std::ostream & os, size_t indentLength) +{ + for(size_t i = 0; i < indentLength; i++) + { + os << " "; + } +} + +bool VulkanHppGenerator::writeStructConstructorArgument(std::ostream & os, bool listedArgument, size_t indentLength, MemberData const& memberData, std::map const& defaultValues) +{ + if (listedArgument) + { + os << ",\n"; + writeIndentation(os, indentLength); + } + + // skip members 'pNext' and 'sType', as they are never explicitly set + if ((memberData.name != "pNext") && (memberData.name != "sType")) + { + // find a default value for the given pure type + std::map::const_iterator defaultIt = defaultValues.find(memberData.pureType); + assert(defaultIt != defaultValues.end()); + + if (memberData.arraySize.empty()) + { + // the arguments name get a trailing '_', to distinguish them from the actual struct members + // pointer arguments get a nullptr as default + os << memberData.type << " " << memberData.name << "_ = " << (memberData.type.back() == '*' ? "nullptr" : defaultIt->second); + } + else + { + // array members are provided as const reference to a std::array + // the arguments name get a trailing '_', to distinguish them from the actual struct members + // list as many default values as there are elements in the array + os << "std::array<" << memberData.type << "," << memberData.arraySize << "> const& " << memberData.name << "_ = { { " << defaultIt->second; + size_t n = atoi(memberData.arraySize.c_str()); + assert(0 < n); + for (size_t j = 1; j < n; j++) + { + os << ", " << defaultIt->second; + } + os << " } }"; + } + listedArgument = true; + } + return listedArgument; +} + +void VulkanHppGenerator::writeStructSetter(std::ostream & os, std::string const& structureName, MemberData const& memberData) +{ + if (memberData.type != "StructureType") // filter out StructureType, which is supposed to be immutable ! + { + // the setters return a reference to the structure + os << " " << structureName << "& set" << startUpperCase(memberData.name) << "( "; + if (memberData.arraySize.empty()) + { + os << memberData.type << " "; + } + else + { + os << "std::array<" << memberData.type << "," << memberData.arraySize << "> "; + } + // add a trailing '_' to the argument to distinguish it from the structure member + os << memberData.name << "_ )" << std::endl + << " {" << std::endl; + // copy over the argument, either by assigning simple data, or by memcpy array data + if (memberData.arraySize.empty()) + { + os << " " << memberData.name << " = " << memberData.name << "_"; + } + else + { + os << " memcpy( &" << memberData.name << ", " << memberData.name << "_.data(), " << memberData.arraySize << " * sizeof( " << memberData.type << " ) )"; + } + os << ";" << std::endl + << " return *this;" << std::endl + << " }" << std::endl + << std::endl; + } +} + +void VulkanHppGenerator::writeStructureChainValidation(std::ostream & os) +{ + // write all template functions for the structure pointer chain validation + for (auto it = m_dependencies.begin(); it != m_dependencies.end(); ++it) + { + if (it->category == DependencyData::Category::STRUCT) + { + writeStructureChainValidation(os, *it); + } + } +} + +void VulkanHppGenerator::writeStructureChainValidation(std::ostream & os, DependencyData const& dependencyData) +{ + std::map::const_iterator it = m_structs.find(dependencyData.name); + assert(it != m_structs.end()); + + if (!it->second.structExtends.empty()) + { + enterProtect(os, it->second.protect); + + // write out allowed structure chains + for (auto extendName : it->second.structExtends) + { + std::map::const_iterator itExtend = m_structs.find(extendName); + if (itExtend == m_structs.end()) { + std::stringstream errorString; + errorString << extendName << " does not specify a struct in structextends field."; + + // check if symbol name is an alias to a struct + auto itAlias = std::find_if(m_structs.begin(), m_structs.end(), [&extendName](std::pair const &it) -> bool {return it.second.alias == extendName;}); + if (itAlias != m_structs.end()) + { + errorString << " The symbol is an alias and maps to " << itAlias->first << "."; + } + + errorString << std::endl; + throw std::runtime_error(errorString.str()); + } + enterProtect(os, itExtend->second.protect); + + os << " template <> struct isStructureChainValid<" << extendName << ", " << dependencyData.name << ">{ enum { value = true }; };" << std::endl; + + leaveProtect(os, itExtend->second.protect); + } + leaveProtect(os, it->second.protect); + } +} + +void VulkanHppGenerator::writeThrowExceptions(std::ostream & os, EnumData const& enumData) +{ + enterProtect(os, enumData.protect); + os << + R"( VULKAN_HPP_INLINE void throwResultException( Result result, char const * message ) + { + switch ( result ) + { +)"; + for (size_t i = 0; icategory) + { + case DependencyData::Category::BITMASK: + writeBitmaskToString(os, it->name, m_enums.find(*it->dependencies.begin())->second); + break; + case DependencyData::Category::ENUM: + assert(m_enums.find(it->name) != m_enums.end()); + writeEnumsToString(os, m_enums.find(it->name)->second); + break; + default: + break; + } + } +} + +void VulkanHppGenerator::writeTypeBitmask(std::ostream & os, std::string const& bitmaskName, BitmaskData const& bitmaskData, EnumData const& enumData) +{ + enterProtect(os, bitmaskData.protect); + + // each Flags class is using on the class 'Flags' with the corresponding FlagBits enum as the template parameter + os << " using " << bitmaskName << " = Flags<" << enumData.name << ", Vk" << bitmaskName << ">;" << std::endl; + + std::stringstream allFlags; + for (size_t i = 0; i < enumData.values.size(); i++) + { + if (i != 0) + { + allFlags << " | "; + } + allFlags << "VkFlags(" << enumData.name << "::" << enumData.values[i].name << ")"; + } + + if (!enumData.values.empty()) + { + const std::string templateString = R"( + VULKAN_HPP_INLINE ${bitmaskName} operator|( ${enumName} bit0, ${enumName} bit1 ) + { + return ${bitmaskName}( bit0 ) | bit1; + } + + VULKAN_HPP_INLINE ${bitmaskName} operator~( ${enumName} bits ) + { + return ~( ${bitmaskName}( bits ) ); + } + + template <> struct FlagTraits<${enumName}> + { + enum + { + allFlags = ${allFlags} + }; + }; +)"; + os << replaceWithMap(templateString, { { "bitmaskName", bitmaskName },{ "enumName", enumData.name },{ "allFlags", allFlags.str() } }); + } + + if (!bitmaskData.alias.empty()) + { + os << std::endl + << " using " << bitmaskData.alias << " = " << bitmaskName << ";" << std::endl; + } + + leaveProtect(os, bitmaskData.protect); + os << std::endl; +} + +void VulkanHppGenerator::writeTypeCommand(std::ostream & os, DependencyData const& dependencyData) +{ + assert(m_commands.find(dependencyData.name) != m_commands.end()); + CommandData const& commandData = m_commands.find(dependencyData.name)->second; + if (commandData.className.empty()) + { + if (commandData.fullName == "createInstance") + { + // special handling for createInstance, as we need to explicitly place the forward declarations and the deleter classes here +#if !defined(NDEBUG) + auto deleterTypesIt = m_deleterTypes.find(""); + assert((deleterTypesIt != m_deleterTypes.end()) && (deleterTypesIt->second.size() == 2)); + assert(deleterTypesIt->second.find("Instance") != deleterTypesIt->second.end()); +#endif + + writeUniqueTypes(os, std::make_pair>("", { "Instance" })); + writeTypeCommand(os, " ", commandData, false); + } + else + { + writeTypeCommand(os, " ", commandData, false); + } + writeTypeCommand(os, " ", commandData, true); + os << std::endl; + } +} + +void VulkanHppGenerator::writeTypeCommand(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool definition) +{ + enterProtect(os, commandData.protect); + + bool isStructureChain = m_extendedStructs.find(commandData.enhancedReturnType) != m_extendedStructs.end(); + + // first create the standard version of the function + std::ostringstream standard; + writeFunction(standard, indentation, commandData, definition, false, false, false, false); + + // then the enhanced version, composed by up to five parts + std::ostringstream enhanced; + writeFunction(enhanced, indentation, commandData, definition, true, false, false, false); + + if (isStructureChain) + { + writeFunction(enhanced, indentation, commandData, definition, true, false, false, true); + } + + // then a singular version, if a sized vector would be returned + std::map::const_iterator returnVector = commandData.vectorParams.find(commandData.returnParam); + bool singular = (returnVector != commandData.vectorParams.end()) && + (returnVector->second != INVALID_INDEX) && + (commandData.params[returnVector->first].pureType != "void") && + (commandData.params[returnVector->second].type.back() != '*'); + if (singular) + { + writeFunction(enhanced, indentation, commandData, definition, true, true, false, false); + } + + // special handling for createDevice and createInstance ! + bool specialWriteUnique = (commandData.reducedName == "createDevice") || (commandData.reducedName == "createInstance"); + + // and then the same for the Unique* versions (a Deleter is available for the commandData's class, and the function starts with 'allocate' or 'create') + if (((m_deleters.find(commandData.className) != m_deleters.end()) || specialWriteUnique) && ((commandData.reducedName.substr(0, 8) == "allocate") || (commandData.reducedName.substr(0, 6) == "create"))) + { + enhanced << "#ifndef VULKAN_HPP_NO_SMART_HANDLE" << std::endl; + writeFunction(enhanced, indentation, commandData, definition, true, false, true, false); + + if (singular) + { + writeFunction(enhanced, indentation, commandData, definition, true, true, true, false); + } + enhanced << "#endif /*VULKAN_HPP_NO_SMART_HANDLE*/" << std::endl; + } + + // and write one or both of them + writeStandardOrEnhanced(os, standard.str(), enhanced.str()); + + leaveProtect(os, commandData.protect); + os << std::endl; +} + +void VulkanHppGenerator::writeTypeEnum(std::ostream & os, EnumData const& enumData) +{ + // a named enum per enum, listing all its values by setting them to the original Vulkan names + enterProtect(os, enumData.protect); + os << " enum class " << enumData.name << std::endl + << " {" << std::endl; + for (size_t i = 0; i list them first + if (!dependencyData.forwardDependencies.empty()) + { + os << " // forward declarations" << std::endl; + for (std::set::const_iterator it = dependencyData.forwardDependencies.begin(); it != dependencyData.forwardDependencies.end(); ++it) + { + assert(m_structs.find(*it) != m_structs.end()); + os << " struct " << *it << ";" << std::endl; + } + os << std::endl; + } + + // then write any forward declaration of Deleters used by this handle + std::map>::const_iterator deleterTypesIt = m_deleterTypes.find(dependencyData.name); + if (deleterTypesIt != m_deleterTypes.end()) + { + writeUniqueTypes(os, *deleterTypesIt); + } + else if (dependencyData.name == "PhysicalDevice") + { + // special handling for class Device, as it's created from PhysicalDevice, but destroys itself + writeUniqueTypes(os, std::make_pair>("", { "Device" })); + } + + const std::string memberName = startLowerCase(dependencyData.name); + const std::string templateString = + R"( class ${className} + { + public: + VULKAN_HPP_CONSTEXPR ${className}() + : m_${memberName}(VK_NULL_HANDLE) + {} + + VULKAN_HPP_CONSTEXPR ${className}( std::nullptr_t ) + : m_${memberName}(VK_NULL_HANDLE) + {} + + VULKAN_HPP_TYPESAFE_EXPLICIT ${className}( Vk${className} ${memberName} ) + : m_${memberName}( ${memberName} ) + {} + +#if defined(VULKAN_HPP_TYPESAFE_CONVERSION) + ${className} & operator=(Vk${className} ${memberName}) + { + m_${memberName} = ${memberName}; + return *this; + } +#endif + + ${className} & operator=( std::nullptr_t ) + { + m_${memberName} = VK_NULL_HANDLE; + return *this; + } + + bool operator==( ${className} const & rhs ) const + { + return m_${memberName} == rhs.m_${memberName}; + } + + bool operator!=(${className} const & rhs ) const + { + return m_${memberName} != rhs.m_${memberName}; + } + + bool operator<(${className} const & rhs ) const + { + return m_${memberName} < rhs.m_${memberName}; + } + +${commands} + + VULKAN_HPP_TYPESAFE_EXPLICIT operator Vk${className}() const + { + return m_${memberName}; + } + + explicit operator bool() const + { + return m_${memberName} != VK_NULL_HANDLE; + } + + bool operator!() const + { + return m_${memberName} == VK_NULL_HANDLE; + } + + private: + Vk${className} m_${memberName}; + }; + + static_assert( sizeof( ${className} ) == sizeof( Vk${className} ), "handle and wrapper have different size!" ); + +)"; + + std::ostringstream commands; + // now list all the commands that are mapped to members of this class + for (size_t i = 0; i < handleData.commands.size(); i++) + { + std::map::const_iterator cit = m_commands.find(handleData.commands[i]); + assert((cit != m_commands.end()) && !cit->second.className.empty()); + writeTypeCommand(commands, " ", cit->second, false); + + // special handling for destroy functions which are not aliased. + if (!cit->second.isAlias && (((cit->second.fullName.substr(0, 7) == "destroy") && (cit->second.reducedName != "destroy")) || (cit->second.fullName.substr(0, 4) == "free"))) + { + CommandData shortenedCommand = cit->second; + shortenedCommand.reducedName = (cit->second.fullName.substr(0, 7) == "destroy") ? "destroy" : "free"; + writeTypeCommand(commands, " ", shortenedCommand, false); + } + } + + os << replaceWithMap(templateString, { + { "className", dependencyData.name }, + { "memberName", memberName }, + { "commands", commands.str() } + }); + + // and finally the commands, that are member functions of this handle + for (size_t i = 0; i < handleData.commands.size(); i++) + { + std::string commandName = handleData.commands[i]; + std::map::const_iterator cit = m_commands.find(commandName); + assert((cit != m_commands.end()) && !cit->second.className.empty()); + std::list::const_iterator dep = std::find_if(m_dependencies.begin(), m_dependencies.end(), [commandName](DependencyData const& dd) { return dd.name == commandName; }); + assert(dep != m_dependencies.end() && (dep->name == cit->second.fullName)); + writeTypeCommand(os, " ", cit->second, true); + + // special handling for destroy functions + if (!cit->second.isAlias && (((cit->second.fullName.substr(0, 7) == "destroy") && (cit->second.reducedName != "destroy")) || (cit->second.fullName.substr(0, 4) == "free"))) + { + CommandData shortenedCommand = cit->second; + shortenedCommand.reducedName = (cit->second.fullName.substr(0, 7) == "destroy") ? "destroy" : "free"; + writeTypeCommand(os, " ", shortenedCommand, true); + } + } + + if (!handleData.alias.empty()) + { + os << " using " << handleData.alias << " = " << dependencyData.name << ";" << std::endl + << std::endl; + } + + leaveProtect(os, handleData.protect); +} + +void VulkanHppGenerator::writeTypes(std::ostream & os, std::map const& defaultValues) +{ + assert(m_deleterTypes.find("") != m_deleterTypes.end()); + + for (std::list::const_iterator it = m_dependencies.begin(); it != m_dependencies.end(); ++it) + { + switch (it->category) + { + case DependencyData::Category::BITMASK: + assert(m_bitmasks.find(it->name) != m_bitmasks.end()); + writeTypeBitmask(os, it->name, m_bitmasks.find(it->name)->second, m_enums.find(generateEnumNameForFlags(it->name))->second); + break; + case DependencyData::Category::COMMAND: + writeTypeCommand(os, *it); + break; + case DependencyData::Category::ENUM: + assert(m_enums.find(it->name) != m_enums.end()); + writeTypeEnum(os, m_enums.find(it->name)->second); + break; + case DependencyData::Category::FUNC_POINTER: + case DependencyData::Category::REQUIRED: + // skip FUNC_POINTER and REQUIRED, they just needed to be in the dependencies list to resolve dependencies + break; + case DependencyData::Category::HANDLE: + assert(m_handles.find(it->name) != m_handles.end()); + writeTypeHandle(os, *it, m_handles.find(it->name)->second); + break; + case DependencyData::Category::SCALAR: + writeTypeScalar(os, *it); + break; + case DependencyData::Category::STRUCT: + writeTypeStruct(os, *it, defaultValues); + break; + case DependencyData::Category::UNION: + assert(m_structs.find(it->name) != m_structs.end()); + writeTypeUnion(os, *it, defaultValues); + break; + default: + assert(false); + break; + } + } +} + +void VulkanHppGenerator::writeTypeScalar(std::ostream & os, DependencyData const& dependencyData) +{ + assert(dependencyData.dependencies.size() == 1); + os << " using " << dependencyData.name << " = " << *dependencyData.dependencies.begin() << ";" << std::endl + << std::endl; +} + +void VulkanHppGenerator::writeTypeStruct(std::ostream & os, DependencyData const& dependencyData, std::map const& defaultValues) +{ + std::map::const_iterator it = m_structs.find(dependencyData.name); + assert(it != m_structs.end()); + + enterProtect(os, it->second.protect); + os << " struct " << dependencyData.name << std::endl + << " {" << std::endl; + + // only structs that are not returnedOnly get a constructor! + if (!it->second.returnedOnly) + { + writeStructConstructor(os, dependencyData.name, it->second, defaultValues); + } + + // create the setters + if (!it->second.returnedOnly) + { + for (size_t i = 0; i < it->second.members.size(); i++) + { + writeStructSetter(os, dependencyData.name, it->second.members[i]); + } + } + + // the implicit cast-operators to the native type + os << " operator Vk" << dependencyData.name << " const&() const" << std::endl + << " {" << std::endl + << " return *reinterpret_cast(this);" << std::endl + << " }" << std::endl + << std::endl + << " operator Vk" << dependencyData.name << " &()" << std::endl + << " {" << std::endl + << " return *reinterpret_cast(this);" << std::endl + << " }" << std::endl + << std::endl; + + // operator==() and operator!=() + // only structs without a union as a member can have a meaningfull == and != operation; we filter them out + if (!containsUnion(dependencyData.name, m_structs)) + { + // two structs are compared by comparing each of the elements + os << " bool operator==( " << dependencyData.name << " const& rhs ) const" << std::endl + << " {" << std::endl + << " return "; + for (size_t i = 0; i < it->second.members.size(); i++) + { + if (i != 0) + { + os << std::endl << " && "; + } + if (!it->second.members[i].arraySize.empty()) + { + os << "( memcmp( " << it->second.members[i].name << ", rhs." << it->second.members[i].name << ", " << it->second.members[i].arraySize << " * sizeof( " << it->second.members[i].type << " ) ) == 0 )"; + } + else + { + os << "( " << it->second.members[i].name << " == rhs." << it->second.members[i].name << " )"; + } + } + os << ";" << std::endl + << " }" << std::endl + << std::endl + << " bool operator!=( " << dependencyData.name << " const& rhs ) const" << std::endl + << " {" << std::endl + << " return !operator==( rhs );" << std::endl + << " }" << std::endl + << std::endl; + } + + // the member variables + for (size_t i = 0; i < it->second.members.size(); i++) + { + if (it->second.members[i].type == "StructureType") + { + assert((i == 0) && (it->second.members[i].name == "sType")); + if (!it->second.members[i].values.empty()) + { + assert(!it->second.members[i].values.empty()); + auto nameIt = m_nameMap.find(it->second.members[i].values); + assert(nameIt != m_nameMap.end()); + os << " private:" << std::endl + << " StructureType sType = " << nameIt->second << ";" << std::endl + << std::endl + << " public:" << std::endl; + } + else + { + os << " StructureType sType;" << std::endl; + } + } + else + { + os << " " << it->second.members[i].type << " " << it->second.members[i].name; + if (it->second.members[i].name == "pNext") + { + os << " = nullptr"; + } + else if (!it->second.members[i].arraySize.empty()) + { + os << "[" << it->second.members[i].arraySize << "]"; + } + os << ";" << std::endl; + } + } + os << " };" << std::endl + << " static_assert( sizeof( " << dependencyData.name << " ) == sizeof( Vk" << dependencyData.name << " ), \"struct and wrapper have different size!\" );" << std::endl; + + if (!it->second.alias.empty()) + { + os << std::endl + << " using " << it->second.alias << " = " << dependencyData.name << ";" << std::endl; + } + + leaveProtect(os, it->second.protect); + os << std::endl; +} + +void VulkanHppGenerator::writeUniqueTypes(std::ostream &os, std::pair> const& deleterTypes) +{ + os << "#ifndef VULKAN_HPP_NO_SMART_HANDLE" << std::endl; + if (!deleterTypes.first.empty()) + { + os << " class " << deleterTypes.first << ";" << std::endl; + } + os << std::endl; + + for (auto const& dt : deleterTypes.second) + { + auto ddit = m_deleters.find(dt); + assert(ddit != m_deleters.end()); + + std::string deleterType = (deleterTypes.first.empty() ? "NoParent" : deleterTypes.first); + + os << " template class UniqueHandleTraits<" << dt << ",Dispatch> {public: " << "using owner = " << deleterType << "; " << "using deleter = " << (ddit->second.pool.empty() ? "Object" : "Pool") << ((ddit->second.call.substr(0, 4) == "free") ? "Free<" : "Destroy<") << (deleterTypes.first.empty() ? "NoParent" : deleterTypes.first) << (ddit->second.pool.empty() ? "" : ", " + ddit->second.pool) << ",Dispatch>; };\n"; + os << " using Unique" << dt << " = UniqueHandle<" << dt << ",DispatchLoaderStatic>;" << std::endl; + } + os << "#endif /*VULKAN_HPP_NO_SMART_HANDLE*/" << std::endl + << std::endl; +} + +void VulkanHppGenerator::writeTypeUnion(std::ostream & os, DependencyData const& dependencyData, std::map const& defaultValues) +{ + std::map::const_iterator it = m_structs.find(dependencyData.name); + assert(it != m_structs.end()); + + std::ostringstream oss; + os << " union " << dependencyData.name << std::endl + << " {" << std::endl; + + for (size_t i = 0; isecond.members.size(); i++) + { + // one constructor per union element + os << " " << dependencyData.name << "( "; + if (it->second.members[i].arraySize.empty()) + { + os << it->second.members[i].type << " "; + } + else + { + os << "const std::array<" << it->second.members[i].type << "," << it->second.members[i].arraySize << ">& "; + } + os << it->second.members[i].name << "_"; + + // just the very first constructor gets default arguments + if (i == 0) + { + std::map::const_iterator defaultIt = defaultValues.find(it->second.members[i].pureType); + assert(defaultIt != defaultValues.end()); + if (it->second.members[i].arraySize.empty()) + { + os << " = " << defaultIt->second; + } + else + { + os << " = { {" << defaultIt->second << "} }"; + } + } + os << " )" << std::endl + << " {" << std::endl + << " "; + if (it->second.members[i].arraySize.empty()) + { + os << it->second.members[i].name << " = " << it->second.members[i].name << "_"; + } + else + { + os << "memcpy( &" << it->second.members[i].name << ", " << it->second.members[i].name << "_.data(), " << it->second.members[i].arraySize << " * sizeof( " << it->second.members[i].type << " ) )"; + } + os << ";" << std::endl + << " }" << std::endl + << std::endl; + } + + for (size_t i = 0; isecond.members.size(); i++) + { + // one setter per union element + assert(!it->second.returnedOnly); + writeStructSetter(os, dependencyData.name, it->second.members[i]); + } + + // the implicit cast operators to the native type + os << " operator Vk" << dependencyData.name << " const&() const" << std::endl + << " {" << std::endl + << " return *reinterpret_cast(this);" << std::endl + << " }" << std::endl + << std::endl + << " operator Vk" << dependencyData.name << " &()" << std::endl + << " {" << std::endl + << " return *reinterpret_cast(this);" << std::endl + << " }" << std::endl + << std::endl; + + // the union member variables + // if there's at least one Vk... type in this union, check for unrestricted unions support + bool needsUnrestrictedUnions = false; + for (size_t i = 0; i < it->second.members.size() && !needsUnrestrictedUnions; i++) + { + needsUnrestrictedUnions = (m_vkTypes.find(it->second.members[i].type) != m_vkTypes.end()); + } + if (needsUnrestrictedUnions) + { + os << "#ifdef VULKAN_HPP_HAS_UNRESTRICTED_UNIONS" << std::endl; + for (size_t i = 0; i < it->second.members.size(); i++) + { + os << " " << it->second.members[i].type << " " << it->second.members[i].name; + if (!it->second.members[i].arraySize.empty()) + { + os << "[" << it->second.members[i].arraySize << "]"; + } + os << ";" << std::endl; + } + os << "#else" << std::endl; + } + for (size_t i = 0; i < it->second.members.size(); i++) + { + os << " "; + if (m_vkTypes.find(it->second.members[i].type) != m_vkTypes.end()) + { + os << "Vk"; + } + os << it->second.members[i].type << " " << it->second.members[i].name; + if (!it->second.members[i].arraySize.empty()) + { + os << "[" << it->second.members[i].arraySize << "]"; + } + os << ";" << std::endl; + } + if (needsUnrestrictedUnions) + { + os << "#endif // VULKAN_HPP_HAS_UNRESTRICTED_UNIONS" << std::endl; + } + os << " };" << std::endl + << std::endl; +} + +#if !defined(NDEBUG) +void VulkanHppGenerator::checkExtensionRequirements() +{ + for (auto const& ext : m_extensions) + { + for (auto const& req : ext.second.requires) + { + auto reqExt = m_extensions.find(req); + assert(reqExt != m_extensions.end()); + assert(reqExt->second.protect.empty() || (reqExt->second.protect == ext.second.protect)); + } + } +} + +void VulkanHppGenerator::skipVendorID(tinyxml2::XMLElement const* element) +{ + std::map attributes = getAttributes(element); + checkAttributes(attributes, element->GetLineNum(), { { "comment",{} },{ "id",{} },{ "name",{} } }, {}); + checkElements(getChildElements(element), {}); + + VendorIDData vendorID; + for (auto const& attribute : attributes) + { + std::string name = attribute.first; + if (name == "comment") + { + vendorID.comment = attribute.second; + } + else if (name == "id") + { + vendorID.id = attribute.second; + } + else + { + assert(name == "name"); + vendorID.name = attribute.second; + } + } + m_vendorIDs.push_back(vendorID); +} + +void VulkanHppGenerator::skipVendorIDs(tinyxml2::XMLElement const* element) +{ + checkAttributes(getAttributes(element), element->GetLineNum(), { { "comment",{} } }, {}); + std::vector children = getChildElements(element); + checkElements(children, { "vendorid" }); + + for (auto child : children) + { + skipVendorID(child); + } +} +#endif + +void VulkanHppGenerator::EnumData::addEnumValue(std::string const &enumName, std::string const& tag, std::map & nameMap) +{ + EnumValueData evd; + evd.name = createEnumValueName(enumName, prefix, postfix, bitmask, tag); + evd.value = enumName; + + auto it = std::find_if(values.begin(), values.end(), [&evd](EnumValueData const& _evd) { return _evd.name == evd.name; }); + if (it == values.end()) + { + values.push_back(evd); + assert(nameMap.find(enumName) == nameMap.end()); + nameMap[enumName] = this->name + "::" + evd.name; + } + else + { + assert(it->value == evd.value); + } +} + +void VulkanHppGenerator::writeDelegationClassStatic(std::ostream &os) +{ + os << "class DispatchLoaderStatic" << std::endl + << "{" << std::endl + << "public:\n"; + + for (auto command : m_commands) + { + enterProtect(os, command.second.protect); + os << " " << command.second.unchangedReturnType << " vk" << startUpperCase(command.second.fullName) << "( "; + bool first = true; + for (auto param : command.second.params) + { + if (!first) { + os << ", "; + } + os << param.unchangedType << " " << param.name; + if (!param.arraySize.empty()) + { + os << "[" << param.arraySize << "]"; + } + first = false; + } + os << " ) const\n" + << " {\n" + << " return ::vk" << startUpperCase(command.second.fullName) << "( "; + first = true; + for (auto param : command.second.params) + { + if (!first) { + os << ", "; + } + os << param.name; + first = false; + } + os << ");\n"; + os << " }\n"; + leaveProtect(os, command.second.protect); + } + os << "};\n"; +} + +void VulkanHppGenerator::writeDelegationClassDynamic(std::ostream &os) +{ + os << " class DispatchLoaderDynamic" << std::endl + << " {" << std::endl + << " public:" << std::endl; + + for (auto command : m_commands) + { + enterProtect(os, command.second.protect); + os << " PFN_vk" << startUpperCase(command.second.fullName) << " vk" << startUpperCase(command.second.fullName) << " = 0;" << std::endl; + leaveProtect(os, command.second.protect); + } + + // write initialization function to fetch function pointers + os << " public:" << std::endl + << " DispatchLoaderDynamic(Instance instance = Instance(), Device device = Device())" << std::endl + << " {" << std::endl + << " if (instance)" << std::endl + << " {" << std::endl + << " init(instance, device);" << std::endl + << " }" << std::endl + << " }" << std::endl << std::endl + << " void init(Instance instance, Device device = Device())" << std::endl + << " {" << std::endl; + + for (auto command : m_commands) + { + enterProtect(os, command.second.protect); + if (!command.second.params.empty() + && m_handles.find(command.second.params[0].type) != m_handles.end() + && command.second.params[0].type != "Instance" + && command.second.params[0].type != "PhysicalDevice") + { + os << " vk" << startUpperCase(command.second.fullName) << " = PFN_vk" << startUpperCase(command.second.fullName) + << "(device ? device.getProcAddr( \"vk" << startUpperCase(command.second.fullName) << "\") : instance.getProcAddr( \"vk" << startUpperCase(command.second.fullName) << "\"));" << std::endl; + } + else { + os << " vk" << startUpperCase(command.second.fullName) << " = PFN_vk" << startUpperCase(command.second.fullName) << "(instance.getProcAddr( \"vk" << startUpperCase(command.second.fullName) << "\"));" << std::endl; + } + leaveProtect(os, command.second.protect); + } + os << " }" << std::endl; + os << " };\n"; +} + +int main( int argc, char **argv ) +{ + try { + tinyxml2::XMLDocument doc; + + std::string filename = (argc == 1) ? VK_SPEC : argv[1]; + std::cout << "Loading vk.xml from " << filename << std::endl; + std::cout << "Writing vulkan.hpp to " << VULKAN_HPP_FILE << std::endl; + + tinyxml2::XMLError error = doc.LoadFile(filename.c_str()); + if (error != tinyxml2::XML_SUCCESS) + { + std::cout << "VkGenerate: failed to load file " << filename << " . Error code: " << error << std::endl; + return -1; + } + + VulkanHppGenerator generator; + + bool foundLicense = false; + + tinyxml2::XMLElement const* registryElement = doc.FirstChildElement(); + checkAttributes(getAttributes(registryElement), registryElement->GetLineNum(), {}, {}); + assert(strcmp(registryElement->Value(), "registry") == 0); + assert(!registryElement->NextSiblingElement()); + + std::vector children = getChildElements(registryElement); + checkElements(children, { "commands", "comment", "enums", "extensions", "feature", "tags", "types", "vendorids", "platforms" }); + for (auto child : children) + { + const std::string value = child->Value(); + if (value == "commands") + { + generator.readCommands(child); + } + else if (value == "comment") + { + if (!foundLicense) + { + // get the vulkan license header and skip any leading spaces + generator.readComment(child); + foundLicense = true; + } + } + else if (value == "enums") + { + generator.readEnums(child); + } + else if (value == "extensions") + { + generator.readExtensions(child); + } + else if (value == "feature") + { + generator.readFeature(child); + } + else if (value == "tags") + { + generator.readTags(child); + } + else if (value == "types") + { + generator.readTypes(child); + } + else if (value == "vendorids") + { +#if !defined(NDEBUG) + generator.skipVendorIDs(child); +#endif + } + else if (value == "platforms") + { + // skip this tag + } + else + { + std::stringstream lineNumber; + lineNumber << child->GetLineNum(); + std::cerr << "warning: Unhandled tag " << value << " at line number: " << lineNumber.str() << "!" << std::endl; + } + } + + generator.sortDependencies(); + +#if !defined(NDEBUG) + generator.checkExtensionRequirements(); +#endif + + std::map defaultValues = generator.createDefaults(); + + std::ofstream ofs(VULKAN_HPP_FILE); + ofs << generator.getVulkanLicenseHeader() << std::endl + << R"( +#ifndef VULKAN_HPP +#define VULKAN_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE +# include +# include +#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ +#if !defined(VULKAN_HPP_ASSERT) +# include +# define VULKAN_HPP_ASSERT assert +#endif + +// includes through some other header +// this results in major(x) being resolved to gnu_dev_major(x) +// which is an expression in a constructor initializer list. +#if defined(major) + #undef major +#endif +#if defined(minor) + #undef minor +#endif + +// Windows defines MemoryBarrier which is deprecated and collides +// with the vk::MemoryBarrier struct. +#ifdef MemoryBarrier + #undef MemoryBarrier +#endif + +)"; + + writeVersionCheck(ofs, generator.getVersion()); + writeTypesafeCheck(ofs, generator.getTypesafeCheck()); + ofs << versionCheckHeader + << inlineHeader + << explicitHeader + << constExprHeader + << std::endl + << vkNamespace + << flagsHeader + << optionalClassHeader + << arrayProxyHeader + << uniqueHandleHeader + << structureChainHeader; + + // first of all, write out vk::Result and the exception handling stuff + generator.writeResultEnum(ofs); + + ofs << "} // namespace VULKAN_HPP_NAMESPACE" << std::endl + << std::endl + << "namespace std" << std::endl + << "{" << std::endl + << " template <>" << std::endl + << " struct is_error_code_enum : public true_type" << std::endl + << " {};" << std::endl + << "}" << std::endl + << std::endl + << "namespace VULKAN_HPP_NAMESPACE" << std::endl + << "{" << std::endl + << resultValueHeader + << createResultValueHeader; + generator.writeDelegationClassStatic(ofs); + ofs << deleterClassString; + + generator.writeTypes(ofs, defaultValues); + generator.writeStructureChainValidation(ofs); + generator.writeToStringFunctions(ofs); + + generator.writeDelegationClassDynamic(ofs); + + ofs << "} // namespace VULKAN_HPP_NAMESPACE" << std::endl + << std::endl + << "#endif" << std::endl; + } + catch (std::exception const& e) + { + std::cout << "caught exception: " << e.what() << std::endl; + return -1; + } + catch (...) + { + std::cout << "caught unknown exception" << std::endl; + return -1; + } +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..c74563d --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,45 @@ +# Copyright(c) 2018, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.2) + +project(Vulkan-Hpp_Tests) + +option (TESTS_BUILD_WITH_LOCAL_VULKAN_HPP OFF) + +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + add_definitions(-DNOMINMAX -DVK_USE_PLATFORM_WIN32_KHR) +else() + error("unhandled platform !") +endif() + +FILE (GLOB linkunits ${CMAKE_CURRENT_SOURCE_DIR}/*) + +if (TESTS_BUILD_WITH_LOCAL_VULKAN_HPP) + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../Vulkan-Docs/include") + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..") +else() + include_directories("$ENV{VK_SDK_PATH}/include") +endif() + +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../glm") + +FOREACH( linkunit ${linkunits} ) + if( IS_DIRECTORY ${linkunit} ) + if( EXISTS ${linkunit}/CMakeLists.txt ) + string( REGEX REPLACE "^.*/([^/]*)$" "\\1" LINK_NAME ${linkunit} ) + add_subdirectory( ${LINK_NAME} ) + endif() + endif() +ENDFOREACH( linkunit ${linkunits} ) diff --git a/tests/DeviceFunctions/CMakeLists.txt b/tests/DeviceFunctions/CMakeLists.txt new file mode 100644 index 0000000..664c85f --- /dev/null +++ b/tests/DeviceFunctions/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright(c) 2018, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.2) + +project(DeviceFunctions) + +set(HEADERS +) + +set(SOURCES + DeviceFunctions.cpp +) + +source_group(headers FILES ${HEADERS}) +source_group(sources FILES ${SOURCES}) + +add_executable(DeviceFunctions + ${HEADERS} + ${SOURCES} +) + +set_target_properties(DeviceFunctions PROPERTIES FOLDER "Tests") +target_link_libraries(DeviceFunctions "$ENV{VK_SDK_PATH}/Lib/vulkan-1.lib") diff --git a/tests/DeviceFunctions/DeviceFunctions.cpp b/tests/DeviceFunctions/DeviceFunctions.cpp new file mode 100644 index 0000000..cb02e9f --- /dev/null +++ b/tests/DeviceFunctions/DeviceFunctions.cpp @@ -0,0 +1,62 @@ +// Copyright(c) 2018, NVIDIA CORPORATION. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// VulkanHpp Samples : DeviceFunctions +// Compile test on device functions + +#include "vulkan/vulkan.hpp" +#include + +static char const* AppName = "DeviceFunctions"; +static char const* EngineName = "Vulkan.hpp"; + +int main(int /*argc*/, char * /*argv[]*/) +{ + try + { + vk::ApplicationInfo appInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1); + vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo({}, &appInfo)); + std::vector physicalDevices = instance->enumeratePhysicalDevices(); + assert(!physicalDevices.empty()); + + // get the QueueFamilyProperties of the first PhysicalDevice + std::vector queueFamilyProperties = physicalDevices[0].getQueueFamilyProperties(); + + // get the first index into queueFamiliyProperties which supports graphics + size_t graphicsQueueFamilyIndex = std::distance(queueFamilyProperties.begin(), + std::find_if(queueFamilyProperties.begin(), + queueFamilyProperties.end(), + [](vk::QueueFamilyProperties const& qfp) { return qfp.queueFlags & vk::QueueFlagBits::eGraphics; })); + assert(graphicsQueueFamilyIndex < queueFamilyProperties.size()); + + // create a UniqueDevice + float queuePriority = 0.0f; + vk::DeviceQueueCreateInfo deviceQueueCreateInfo(vk::DeviceQueueCreateFlags(), static_cast(graphicsQueueFamilyIndex), 1, &queuePriority); + vk::UniqueDevice device = physicalDevices[0].createDeviceUnique(vk::DeviceCreateInfo(vk::DeviceCreateFlags(), 1, &deviceQueueCreateInfo)); + + std::vector data; + device->getAccelerationStructureHandleNVX({}, data, vk::DispatchLoaderDynamic()); + } + catch (vk::SystemError err) + { + std::cout << "vk::SystemError: " << err.what() << std::endl; + exit(-1); + } + catch (...) + { + std::cout << "unknown error\n"; + exit(-1); + } + return 0; +} diff --git a/tests/StructureChain/CMakeLists.txt b/tests/StructureChain/CMakeLists.txt new file mode 100644 index 0000000..46b8fa0 --- /dev/null +++ b/tests/StructureChain/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright(c) 2018, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.2) + +project(StructureChain) + +set(HEADERS +) + +set(SOURCES + StructureChain.cpp +) + +source_group(headers FILES ${HEADERS}) +source_group(sources FILES ${SOURCES}) + +add_executable(StructureChain + ${HEADERS} + ${SOURCES} +) + +set_target_properties(StructureChain PROPERTIES FOLDER "Tests") +target_link_libraries(StructureChain "$ENV{VK_SDK_PATH}/Lib/vulkan-1.lib") diff --git a/tests/StructureChain/StructureChain.cpp b/tests/StructureChain/StructureChain.cpp new file mode 100644 index 0000000..ea87383 --- /dev/null +++ b/tests/StructureChain/StructureChain.cpp @@ -0,0 +1,86 @@ +// Copyright(c) 2018, NVIDIA CORPORATION. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// VulkanHpp Tests : StructureChain +// Compile-test for StructureChains + +#include "vulkan/vulkan.hpp" +#include + +static char const* AppName = "StructureChain"; +static char const* EngineName = "Vulkan.hpp"; + +#if defined(_MSC_VER) +#pragma warning( disable : 4189 ) +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wunused-variable" +#else +// unknow compiler... just ignore the warnings for yourselves ;) +#endif + +int main(int /*argc*/, char * /*argv[]*/) +{ + try + { + vk::ApplicationInfo appInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1); + vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo({}, &appInfo)); + std::vector physicalDevices = instance->enumeratePhysicalDevices(); + + // some valid StructureChains + vk::StructureChain sc0; + vk::StructureChain sc1; + vk::StructureChain sc2; + vk::StructureChain sc3; + vk::StructureChain sc4; + vk::StructureChain sc6; + vk::StructureChain sc7; + + // some not valid StructureChains + //vk::StructureChain x; + //vk::StructureChain x; + //vk::StructureChain x; + //vk::StructureChain x; + //vk::StructureChain x; + + vk::PhysicalDevice & pd = physicalDevices[0]; + + // simple call, passing structures in + vk::PhysicalDeviceFeatures2 pdf; + pd.getFeatures2(&pdf); + + // simple calls, getting structure back + vk::PhysicalDeviceFeatures2 a = pd.getFeatures2(); + vk::PhysicalDeviceFeatures2 b = pd.getFeatures2(vk::DispatchLoaderStatic()); + + // complex calls, getting StructureChain back + auto c = pd.getFeatures2(); + vk::PhysicalDeviceFeatures2 & c0 = c.get(); + vk::PhysicalDeviceVariablePointerFeatures & c1 = c.get(); + + auto d = pd.getFeatures2(vk::DispatchLoaderStatic()); + vk::PhysicalDeviceFeatures2 & d0 = d.get(); + vk::PhysicalDeviceVariablePointerFeatures & d1 = d.get(); + } + catch (vk::SystemError err) + { + std::cout << "vk::SystemError: " << err.what() << std::endl; + exit(-1); + } + catch (...) + { + std::cout << "unknown error\n"; + exit(-1); + } + return 0; +} diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 2dfe25e..be7d772 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -385,12 +385,17 @@ namespace VULKAN_HPP_NAMESPACE using Owner = typename UniqueHandleTraits::owner; using Deleter = typename UniqueHandleTraits::deleter; public: - explicit UniqueHandle( Type const& value = Type(), Deleter const& deleter = Deleter() ) + + explicit UniqueHandle( Type const& value = Type() ) + : UniqueHandle(value, Deleter()) + {} + + explicit UniqueHandle( Type const& value, Deleter const& deleter = Deleter() ) : Deleter( deleter) , m_value( value ) {} - explicit UniqueHandle( Type const& value = Type(), Owner const& owner = Owner() ) + explicit UniqueHandle( Type const& value, Owner const& owner = Owner() ) : Deleter( owner) , m_value( value ) {} @@ -485,8 +490,34 @@ namespace VULKAN_HPP_NAMESPACE #endif + template struct isStructureChainValid { enum { value = false }; }; + template + struct TypeList + { + using list = P; + using last = T; + }; + + template + struct extendCheck + { + static const bool valid = isStructureChainValid::value || extendCheck::valid; + }; + + template + struct extendCheck,X> + { + static const bool valid = isStructureChainValid::value; + }; + + template + struct extendCheck + { + static const bool valid = true; + }; + template class StructureChainElement { @@ -503,75 +534,78 @@ namespace VULKAN_HPP_NAMESPACE public: StructureChain() { - link(); + link(); } StructureChain(StructureChain const &rhs) { - linkAndCopy(rhs); + linkAndCopy(rhs); } StructureChain(StructureElements const &... elems) { - linkAndCopyElements(elems...); + linkAndCopyElements(elems...); } StructureChain& operator=(StructureChain const &rhs) { - linkAndCopy(rhs); + linkAndCopy(rhs); return *this; } template ClassType& get() { return static_cast(*this);} private: - template + template void link() { + static_assert(extendCheck::valid, "The structure chain is not valid!"); } - template + template void link() { - static_assert(isStructureChainValid::value, "The structure chain is not valid!"); + static_assert(extendCheck::valid, "The structure chain is not valid!"); X& x = static_cast(*this); Y& y = static_cast(*this); x.pNext = &y; - link(); + link, Y, Z...>(); } - template + template void linkAndCopy(StructureChain const &rhs) { + static_assert(extendCheck::valid, "The structure chain is not valid!"); static_cast(*this) = static_cast(rhs); } - template + template void linkAndCopy(StructureChain const &rhs) { - static_assert(isStructureChainValid::value, "The structure chain is not valid!"); + static_assert(extendCheck::valid, "The structure chain is not valid!"); X& x = static_cast(*this); Y& y = static_cast(*this); x = static_cast(rhs); x.pNext = &y; - linkAndCopy(rhs); + linkAndCopy, Y, Z...>(rhs); } - template + template void linkAndCopyElements(X const &xelem) { + static_assert(extendCheck::valid, "The structure chain is not valid!"); static_cast(*this) = xelem; } - template + template void linkAndCopyElements(X const &xelem, Y const &yelem, Z const &... zelem) { - static_assert(isStructureChainValid::value, "The structure chain is not valid!"); + static_assert(extendCheck::valid, "The structure chain is not valid!"); X& x = static_cast(*this); Y& y = static_cast(*this); x = xelem; x.pNext = &y; - linkAndCopyElements(yelem, zelem...); + linkAndCopyElements, Y, Z...>(yelem, zelem...); } }; @@ -4907,11 +4941,16 @@ public: return *this; } - operator const VkOffset2D&() const + operator VkOffset2D const&() const { return *reinterpret_cast(this); } + operator VkOffset2D &() + { + return *reinterpret_cast(this); + } + bool operator==( Offset2D const& rhs ) const { return ( x == rhs.x ) @@ -4974,11 +5013,16 @@ public: return *this; } - operator const VkOffset3D&() const + operator VkOffset3D const&() const { return *reinterpret_cast(this); } + operator VkOffset3D &() + { + return *reinterpret_cast(this); + } + bool operator==( Offset3D const& rhs ) const { return ( x == rhs.x ) @@ -5028,11 +5072,16 @@ public: return *this; } - operator const VkExtent2D&() const + operator VkExtent2D const&() const { return *reinterpret_cast(this); } + operator VkExtent2D &() + { + return *reinterpret_cast(this); + } + bool operator==( Extent2D const& rhs ) const { return ( width == rhs.width ) @@ -5095,11 +5144,16 @@ public: return *this; } - operator const VkExtent3D&() const + operator VkExtent3D const&() const { return *reinterpret_cast(this); } + operator VkExtent3D &() + { + return *reinterpret_cast(this); + } + bool operator==( Extent3D const& rhs ) const { return ( width == rhs.width ) @@ -5181,11 +5235,16 @@ public: return *this; } - operator const VkViewport&() const + operator VkViewport const&() const { return *reinterpret_cast(this); } + operator VkViewport &() + { + return *reinterpret_cast(this); + } + bool operator==( Viewport const& rhs ) const { return ( x == rhs.x ) @@ -5241,11 +5300,16 @@ public: return *this; } - operator const VkRect2D&() const + operator VkRect2D const&() const { return *reinterpret_cast(this); } + operator VkRect2D &() + { + return *reinterpret_cast(this); + } + bool operator==( Rect2D const& rhs ) const { return ( offset == rhs.offset ) @@ -5301,11 +5365,16 @@ public: return *this; } - operator const VkClearRect&() const + operator VkClearRect const&() const { return *reinterpret_cast(this); } + operator VkClearRect &() + { + return *reinterpret_cast(this); + } + bool operator==( ClearRect const& rhs ) const { return ( rect == rhs.rect ) @@ -5326,11 +5395,16 @@ public: struct ExtensionProperties { - operator const VkExtensionProperties&() const + operator VkExtensionProperties const&() const { return *reinterpret_cast(this); } + operator VkExtensionProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( ExtensionProperties const& rhs ) const { return ( memcmp( extensionName, rhs.extensionName, VK_MAX_EXTENSION_NAME_SIZE * sizeof( char ) ) == 0 ) @@ -5349,11 +5423,16 @@ public: struct LayerProperties { - operator const VkLayerProperties&() const + operator VkLayerProperties const&() const { return *reinterpret_cast(this); } + operator VkLayerProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( LayerProperties const& rhs ) const { return ( memcmp( layerName, rhs.layerName, VK_MAX_EXTENSION_NAME_SIZE * sizeof( char ) ) == 0 ) @@ -5437,11 +5516,16 @@ public: return *this; } - operator const VkAllocationCallbacks&() const + operator VkAllocationCallbacks const&() const { return *reinterpret_cast(this); } + operator VkAllocationCallbacks &() + { + return *reinterpret_cast(this); + } + bool operator==( AllocationCallbacks const& rhs ) const { return ( pUserData == rhs.pUserData ) @@ -5468,11 +5552,16 @@ public: struct MemoryRequirements { - operator const VkMemoryRequirements&() const + operator VkMemoryRequirements const&() const { return *reinterpret_cast(this); } + operator VkMemoryRequirements &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryRequirements const& rhs ) const { return ( size == rhs.size ) @@ -5530,11 +5619,16 @@ public: return *this; } - operator const VkDescriptorBufferInfo&() const + operator VkDescriptorBufferInfo const&() const { return *reinterpret_cast(this); } + operator VkDescriptorBufferInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorBufferInfo const& rhs ) const { return ( buffer == rhs.buffer ) @@ -5555,11 +5649,16 @@ public: struct SubresourceLayout { - operator const VkSubresourceLayout&() const + operator VkSubresourceLayout const&() const { return *reinterpret_cast(this); } + operator VkSubresourceLayout &() + { + return *reinterpret_cast(this); + } + bool operator==( SubresourceLayout const& rhs ) const { return ( offset == rhs.offset ) @@ -5621,11 +5720,16 @@ public: return *this; } - operator const VkBufferCopy&() const + operator VkBufferCopy const&() const { return *reinterpret_cast(this); } + operator VkBufferCopy &() + { + return *reinterpret_cast(this); + } + bool operator==( BufferCopy const& rhs ) const { return ( srcOffset == rhs.srcOffset ) @@ -5683,11 +5787,16 @@ public: return *this; } - operator const VkSpecializationMapEntry&() const + operator VkSpecializationMapEntry const&() const { return *reinterpret_cast(this); } + operator VkSpecializationMapEntry &() + { + return *reinterpret_cast(this); + } + bool operator==( SpecializationMapEntry const& rhs ) const { return ( constantID == rhs.constantID ) @@ -5753,11 +5862,16 @@ public: return *this; } - operator const VkSpecializationInfo&() const + operator VkSpecializationInfo const&() const { return *reinterpret_cast(this); } + operator VkSpecializationInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SpecializationInfo const& rhs ) const { return ( mapEntryCount == rhs.mapEntryCount ) @@ -5813,11 +5927,16 @@ public: return *this; } - operator VkClearColorValue const& () const + operator VkClearColorValue const&() const { return *reinterpret_cast(this); } + operator VkClearColorValue &() + { + return *reinterpret_cast(this); + } + float float32[4]; int32_t int32[4]; uint32_t uint32[4]; @@ -5854,11 +5973,16 @@ public: return *this; } - operator const VkClearDepthStencilValue&() const + operator VkClearDepthStencilValue const&() const { return *reinterpret_cast(this); } + operator VkClearDepthStencilValue &() + { + return *reinterpret_cast(this); + } + bool operator==( ClearDepthStencilValue const& rhs ) const { return ( depth == rhs.depth ) @@ -5899,11 +6023,16 @@ public: return *this; } - operator VkClearValue const& () const + operator VkClearValue const&() const { return *reinterpret_cast(this); } + operator VkClearValue &() + { + return *reinterpret_cast(this); + } + #ifdef VULKAN_HPP_HAS_UNRESTRICTED_UNIONS ClearColorValue color; ClearDepthStencilValue depthStencil; @@ -6368,11 +6497,16 @@ public: return *this; } - operator const VkPhysicalDeviceFeatures&() const + operator VkPhysicalDeviceFeatures const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceFeatures &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceFeatures const& rhs ) const { return ( robustBufferAccess == rhs.robustBufferAccess ) @@ -6497,11 +6631,16 @@ public: struct PhysicalDeviceSparseProperties { - operator const VkPhysicalDeviceSparseProperties&() const + operator VkPhysicalDeviceSparseProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceSparseProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceSparseProperties const& rhs ) const { return ( residencyStandard2DBlockShape == rhs.residencyStandard2DBlockShape ) @@ -6571,11 +6710,16 @@ public: return *this; } - operator const VkDrawIndirectCommand&() const + operator VkDrawIndirectCommand const&() const { return *reinterpret_cast(this); } + operator VkDrawIndirectCommand &() + { + return *reinterpret_cast(this); + } + bool operator==( DrawIndirectCommand const& rhs ) const { return ( vertexCount == rhs.vertexCount ) @@ -6651,11 +6795,16 @@ public: return *this; } - operator const VkDrawIndexedIndirectCommand&() const + operator VkDrawIndexedIndirectCommand const&() const { return *reinterpret_cast(this); } + operator VkDrawIndexedIndirectCommand &() + { + return *reinterpret_cast(this); + } + bool operator==( DrawIndexedIndirectCommand const& rhs ) const { return ( indexCount == rhs.indexCount ) @@ -6717,11 +6866,16 @@ public: return *this; } - operator const VkDispatchIndirectCommand&() const + operator VkDispatchIndirectCommand const&() const { return *reinterpret_cast(this); } + operator VkDispatchIndirectCommand &() + { + return *reinterpret_cast(this); + } + bool operator==( DispatchIndirectCommand const& rhs ) const { return ( x == rhs.x ) @@ -6742,11 +6896,16 @@ public: struct DisplayPlanePropertiesKHR { - operator const VkDisplayPlanePropertiesKHR&() const + operator VkDisplayPlanePropertiesKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayPlanePropertiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPlanePropertiesKHR const& rhs ) const { return ( currentDisplay == rhs.currentDisplay ) @@ -6794,11 +6953,16 @@ public: return *this; } - operator const VkDisplayModeParametersKHR&() const + operator VkDisplayModeParametersKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayModeParametersKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayModeParametersKHR const& rhs ) const { return ( visibleRegion == rhs.visibleRegion ) @@ -6817,11 +6981,16 @@ public: struct DisplayModePropertiesKHR { - operator const VkDisplayModePropertiesKHR&() const + operator VkDisplayModePropertiesKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayModePropertiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayModePropertiesKHR const& rhs ) const { return ( displayMode == rhs.displayMode ) @@ -6884,11 +7053,16 @@ public: return *this; } - operator const VkRectLayerKHR&() const + operator VkRectLayerKHR const&() const { return *reinterpret_cast(this); } + operator VkRectLayerKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( RectLayerKHR const& rhs ) const { return ( offset == rhs.offset ) @@ -6938,11 +7112,16 @@ public: return *this; } - operator const VkPresentRegionKHR&() const + operator VkPresentRegionKHR const&() const { return *reinterpret_cast(this); } + operator VkPresentRegionKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( PresentRegionKHR const& rhs ) const { return ( rectangleCount == rhs.rectangleCount ) @@ -6990,11 +7169,16 @@ public: return *this; } - operator const VkXYColorEXT&() const + operator VkXYColorEXT const&() const { return *reinterpret_cast(this); } + operator VkXYColorEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( XYColorEXT const& rhs ) const { return ( x == rhs.x ) @@ -7013,11 +7197,16 @@ public: struct RefreshCycleDurationGOOGLE { - operator const VkRefreshCycleDurationGOOGLE&() const + operator VkRefreshCycleDurationGOOGLE const&() const { return *reinterpret_cast(this); } + operator VkRefreshCycleDurationGOOGLE &() + { + return *reinterpret_cast(this); + } + bool operator==( RefreshCycleDurationGOOGLE const& rhs ) const { return ( refreshDuration == rhs.refreshDuration ); @@ -7034,11 +7223,16 @@ public: struct PastPresentationTimingGOOGLE { - operator const VkPastPresentationTimingGOOGLE&() const + operator VkPastPresentationTimingGOOGLE const&() const { return *reinterpret_cast(this); } + operator VkPastPresentationTimingGOOGLE &() + { + return *reinterpret_cast(this); + } + bool operator==( PastPresentationTimingGOOGLE const& rhs ) const { return ( presentID == rhs.presentID ) @@ -7092,11 +7286,16 @@ public: return *this; } - operator const VkPresentTimeGOOGLE&() const + operator VkPresentTimeGOOGLE const&() const { return *reinterpret_cast(this); } + operator VkPresentTimeGOOGLE &() + { + return *reinterpret_cast(this); + } + bool operator==( PresentTimeGOOGLE const& rhs ) const { return ( presentID == rhs.presentID ) @@ -7144,11 +7343,16 @@ public: return *this; } - operator const VkViewportWScalingNV&() const + operator VkViewportWScalingNV const&() const { return *reinterpret_cast(this); } + operator VkViewportWScalingNV &() + { + return *reinterpret_cast(this); + } + bool operator==( ViewportWScalingNV const& rhs ) const { return ( xcoeff == rhs.xcoeff ) @@ -7196,11 +7400,16 @@ public: return *this; } - operator const VkSampleLocationEXT&() const + operator VkSampleLocationEXT const&() const { return *reinterpret_cast(this); } + operator VkSampleLocationEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( SampleLocationEXT const& rhs ) const { return ( x == rhs.x ) @@ -7219,11 +7428,16 @@ public: struct ShaderResourceUsageAMD { - operator const VkShaderResourceUsageAMD&() const + operator VkShaderResourceUsageAMD const&() const { return *reinterpret_cast(this); } + operator VkShaderResourceUsageAMD &() + { + return *reinterpret_cast(this); + } + bool operator==( ShaderResourceUsageAMD const& rhs ) const { return ( numUsedVgprs == rhs.numUsedVgprs ) @@ -7277,11 +7491,16 @@ public: return *this; } - operator const VkVertexInputBindingDivisorDescriptionEXT&() const + operator VkVertexInputBindingDivisorDescriptionEXT const&() const { return *reinterpret_cast(this); } + operator VkVertexInputBindingDivisorDescriptionEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( VertexInputBindingDivisorDescriptionEXT const& rhs ) const { return ( binding == rhs.binding ) @@ -7356,11 +7575,16 @@ public: return *this; } - operator const VkDescriptorImageInfo&() const + operator VkDescriptorImageInfo const&() const { return *reinterpret_cast(this); } + operator VkDescriptorImageInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorImageInfo const& rhs ) const { return ( sampler == rhs.sampler ) @@ -7410,11 +7634,16 @@ public: return *this; } - operator const VkAttachmentReference&() const + operator VkAttachmentReference const&() const { return *reinterpret_cast(this); } + operator VkAttachmentReference &() + { + return *reinterpret_cast(this); + } + bool operator==( AttachmentReference const& rhs ) const { return ( attachment == rhs.attachment ) @@ -7532,11 +7761,16 @@ public: return *this; } - operator const VkComponentMapping&() const + operator VkComponentMapping const&() const { return *reinterpret_cast(this); } + operator VkComponentMapping &() + { + return *reinterpret_cast(this); + } + bool operator==( ComponentMapping const& rhs ) const { return ( r == rhs.r ) @@ -7603,11 +7837,16 @@ public: return *this; } - operator const VkDescriptorPoolSize&() const + operator VkDescriptorPoolSize const&() const { return *reinterpret_cast(this); } + operator VkDescriptorPoolSize &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorPoolSize const& rhs ) const { return ( type == rhs.type ) @@ -7687,11 +7926,16 @@ public: return *this; } - operator const VkDescriptorUpdateTemplateEntry&() const + operator VkDescriptorUpdateTemplateEntry const&() const { return *reinterpret_cast(this); } + operator VkDescriptorUpdateTemplateEntry &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorUpdateTemplateEntry const& rhs ) const { return ( dstBinding == rhs.dstBinding ) @@ -8010,11 +8254,16 @@ public: return *this; } - operator const VkStencilOpState&() const + operator VkStencilOpState const&() const { return *reinterpret_cast(this); } + operator VkStencilOpState &() + { + return *reinterpret_cast(this); + } + bool operator==( StencilOpState const& rhs ) const { return ( failOp == rhs.failOp ) @@ -8129,11 +8378,16 @@ public: return *this; } - operator const VkVertexInputBindingDescription&() const + operator VkVertexInputBindingDescription const&() const { return *reinterpret_cast(this); } + operator VkVertexInputBindingDescription &() + { + return *reinterpret_cast(this); + } + bool operator==( VertexInputBindingDescription const& rhs ) const { return ( binding == rhs.binding ) @@ -8464,11 +8718,16 @@ public: return *this; } - operator const VkVertexInputAttributeDescription&() const + operator VkVertexInputAttributeDescription const&() const { return *reinterpret_cast(this); } + operator VkVertexInputAttributeDescription &() + { + return *reinterpret_cast(this); + } + bool operator==( VertexInputAttributeDescription const& rhs ) const { return ( location == rhs.location ) @@ -8864,11 +9123,16 @@ public: return *this; } - operator const VkApplicationInfo&() const + operator VkApplicationInfo const&() const { return *reinterpret_cast(this); } + operator VkApplicationInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ApplicationInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -8967,11 +9231,16 @@ public: return *this; } - operator const VkInstanceCreateInfo&() const + operator VkInstanceCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkInstanceCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( InstanceCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9040,11 +9309,16 @@ public: return *this; } - operator const VkMemoryAllocateInfo&() const + operator VkMemoryAllocateInfo const&() const { return *reinterpret_cast(this); } + operator VkMemoryAllocateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryAllocateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9113,11 +9387,16 @@ public: return *this; } - operator const VkMappedMemoryRange&() const + operator VkMappedMemoryRange const&() const { return *reinterpret_cast(this); } + operator VkMappedMemoryRange &() + { + return *reinterpret_cast(this); + } + bool operator==( MappedMemoryRange const& rhs ) const { return ( sType == rhs.sType ) @@ -9228,11 +9507,16 @@ public: return *this; } - operator const VkWriteDescriptorSet&() const + operator VkWriteDescriptorSet const&() const { return *reinterpret_cast(this); } + operator VkWriteDescriptorSet &() + { + return *reinterpret_cast(this); + } + bool operator==( WriteDescriptorSet const& rhs ) const { return ( sType == rhs.sType ) @@ -9345,11 +9629,16 @@ public: return *this; } - operator const VkCopyDescriptorSet&() const + operator VkCopyDescriptorSet const&() const { return *reinterpret_cast(this); } + operator VkCopyDescriptorSet &() + { + return *reinterpret_cast(this); + } + bool operator==( CopyDescriptorSet const& rhs ) const { return ( sType == rhs.sType ) @@ -9444,11 +9733,16 @@ public: return *this; } - operator const VkBufferViewCreateInfo&() const + operator VkBufferViewCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkBufferViewCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BufferViewCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9523,11 +9817,16 @@ public: return *this; } - operator const VkShaderModuleCreateInfo&() const + operator VkShaderModuleCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkShaderModuleCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ShaderModuleCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9598,11 +9897,16 @@ public: return *this; } - operator const VkDescriptorSetAllocateInfo&() const + operator VkDescriptorSetAllocateInfo const&() const { return *reinterpret_cast(this); } + operator VkDescriptorSetAllocateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorSetAllocateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9689,11 +9993,16 @@ public: return *this; } - operator const VkPipelineVertexInputStateCreateInfo&() const + operator VkPipelineVertexInputStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineVertexInputStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineVertexInputStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9768,11 +10077,16 @@ public: return *this; } - operator const VkPipelineInputAssemblyStateCreateInfo&() const + operator VkPipelineInputAssemblyStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineInputAssemblyStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineInputAssemblyStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9835,11 +10149,16 @@ public: return *this; } - operator const VkPipelineTessellationStateCreateInfo&() const + operator VkPipelineTessellationStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineTessellationStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineTessellationStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -9924,11 +10243,16 @@ public: return *this; } - operator const VkPipelineViewportStateCreateInfo&() const + operator VkPipelineViewportStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineViewportStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineViewportStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10067,11 +10391,16 @@ public: return *this; } - operator const VkPipelineRasterizationStateCreateInfo&() const + operator VkPipelineRasterizationStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineRasterizationStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineRasterizationStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10214,11 +10543,16 @@ public: return *this; } - operator const VkPipelineDepthStencilStateCreateInfo&() const + operator VkPipelineDepthStencilStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineDepthStencilStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineDepthStencilStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10303,11 +10637,16 @@ public: return *this; } - operator const VkPipelineCacheCreateInfo&() const + operator VkPipelineCacheCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineCacheCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineCacheCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10482,11 +10821,16 @@ public: return *this; } - operator const VkSamplerCreateInfo&() const + operator VkSamplerCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkSamplerCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SamplerCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10583,11 +10927,16 @@ public: return *this; } - operator const VkCommandBufferAllocateInfo&() const + operator VkCommandBufferAllocateInfo const&() const { return *reinterpret_cast(this); } + operator VkCommandBufferAllocateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( CommandBufferAllocateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10674,11 +11023,16 @@ public: return *this; } - operator const VkRenderPassBeginInfo&() const + operator VkRenderPassBeginInfo const&() const { return *reinterpret_cast(this); } + operator VkRenderPassBeginInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( RenderPassBeginInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10737,11 +11091,16 @@ public: return *this; } - operator const VkEventCreateInfo&() const + operator VkEventCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkEventCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( EventCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10792,11 +11151,16 @@ public: return *this; } - operator const VkSemaphoreCreateInfo&() const + operator VkSemaphoreCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkSemaphoreCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SemaphoreCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10895,11 +11259,16 @@ public: return *this; } - operator const VkFramebufferCreateInfo&() const + operator VkFramebufferCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkFramebufferCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( FramebufferCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -10970,11 +11339,16 @@ public: return *this; } - operator const VkDisplayModeCreateInfoKHR&() const + operator VkDisplayModeCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayModeCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayModeCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11043,11 +11417,16 @@ public: return *this; } - operator const VkDisplayPresentInfoKHR&() const + operator VkDisplayPresentInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayPresentInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPresentInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11111,11 +11490,16 @@ public: return *this; } - operator const VkAndroidSurfaceCreateInfoKHR&() const + operator VkAndroidSurfaceCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkAndroidSurfaceCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( AndroidSurfaceCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11186,11 +11570,16 @@ public: return *this; } - operator const VkMirSurfaceCreateInfoKHR&() const + operator VkMirSurfaceCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkMirSurfaceCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( MirSurfaceCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11255,11 +11644,16 @@ public: return *this; } - operator const VkViSurfaceCreateInfoNN&() const + operator VkViSurfaceCreateInfoNN const&() const { return *reinterpret_cast(this); } + operator VkViSurfaceCreateInfoNN &() + { + return *reinterpret_cast(this); + } + bool operator==( ViSurfaceCreateInfoNN const& rhs ) const { return ( sType == rhs.sType ) @@ -11330,11 +11724,16 @@ public: return *this; } - operator const VkWaylandSurfaceCreateInfoKHR&() const + operator VkWaylandSurfaceCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkWaylandSurfaceCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( WaylandSurfaceCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11407,11 +11806,16 @@ public: return *this; } - operator const VkWin32SurfaceCreateInfoKHR&() const + operator VkWin32SurfaceCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkWin32SurfaceCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( Win32SurfaceCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11484,11 +11888,16 @@ public: return *this; } - operator const VkXlibSurfaceCreateInfoKHR&() const + operator VkXlibSurfaceCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkXlibSurfaceCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( XlibSurfaceCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11561,11 +11970,16 @@ public: return *this; } - operator const VkXcbSurfaceCreateInfoKHR&() const + operator VkXcbSurfaceCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkXcbSurfaceCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( XcbSurfaceCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -11629,11 +12043,16 @@ public: return *this; } - operator const VkDebugMarkerMarkerInfoEXT&() const + operator VkDebugMarkerMarkerInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugMarkerMarkerInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugMarkerMarkerInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -11686,11 +12105,16 @@ public: return *this; } - operator const VkDedicatedAllocationImageCreateInfoNV&() const + operator VkDedicatedAllocationImageCreateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkDedicatedAllocationImageCreateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( DedicatedAllocationImageCreateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -11741,11 +12165,16 @@ public: return *this; } - operator const VkDedicatedAllocationBufferCreateInfoNV&() const + operator VkDedicatedAllocationBufferCreateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkDedicatedAllocationBufferCreateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( DedicatedAllocationBufferCreateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -11804,11 +12233,16 @@ public: return *this; } - operator const VkDedicatedAllocationMemoryAllocateInfoNV&() const + operator VkDedicatedAllocationMemoryAllocateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkDedicatedAllocationMemoryAllocateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( DedicatedAllocationMemoryAllocateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -11870,11 +12304,16 @@ public: return *this; } - operator const VkExportMemoryWin32HandleInfoNV&() const + operator VkExportMemoryWin32HandleInfoNV const&() const { return *reinterpret_cast(this); } + operator VkExportMemoryWin32HandleInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportMemoryWin32HandleInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -11977,11 +12416,16 @@ public: return *this; } - operator const VkWin32KeyedMutexAcquireReleaseInfoNV&() const + operator VkWin32KeyedMutexAcquireReleaseInfoNV const&() const { return *reinterpret_cast(this); } + operator VkWin32KeyedMutexAcquireReleaseInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( Win32KeyedMutexAcquireReleaseInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -12045,11 +12489,16 @@ public: return *this; } - operator const VkDeviceGeneratedCommandsFeaturesNVX&() const + operator VkDeviceGeneratedCommandsFeaturesNVX const&() const { return *reinterpret_cast(this); } + operator VkDeviceGeneratedCommandsFeaturesNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGeneratedCommandsFeaturesNVX const& rhs ) const { return ( sType == rhs.sType ) @@ -12132,11 +12581,16 @@ public: return *this; } - operator const VkDeviceGeneratedCommandsLimitsNVX&() const + operator VkDeviceGeneratedCommandsLimitsNVX const&() const { return *reinterpret_cast(this); } + operator VkDeviceGeneratedCommandsLimitsNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGeneratedCommandsLimitsNVX const& rhs ) const { return ( sType == rhs.sType ) @@ -12211,11 +12665,16 @@ public: return *this; } - operator const VkCmdReserveSpaceForCommandsInfoNVX&() const + operator VkCmdReserveSpaceForCommandsInfoNVX const&() const { return *reinterpret_cast(this); } + operator VkCmdReserveSpaceForCommandsInfoNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( CmdReserveSpaceForCommandsInfoNVX const& rhs ) const { return ( sType == rhs.sType ) @@ -12270,11 +12729,16 @@ public: return *this; } - operator const VkPhysicalDeviceFeatures2&() const + operator VkPhysicalDeviceFeatures2 const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceFeatures2 &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceFeatures2 const& rhs ) const { return ( sType == rhs.sType ) @@ -12327,11 +12791,16 @@ public: return *this; } - operator const VkPhysicalDevicePushDescriptorPropertiesKHR&() const + operator VkPhysicalDevicePushDescriptorPropertiesKHR const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDevicePushDescriptorPropertiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDevicePushDescriptorPropertiesKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12390,11 +12859,16 @@ public: return *this; } - operator const VkPresentRegionsKHR&() const + operator VkPresentRegionsKHR const&() const { return *reinterpret_cast(this); } + operator VkPresentRegionsKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( PresentRegionsKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12455,11 +12929,16 @@ public: return *this; } - operator const VkPhysicalDeviceVariablePointerFeatures&() const + operator VkPhysicalDeviceVariablePointerFeatures const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceVariablePointerFeatures &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceVariablePointerFeatures const& rhs ) const { return ( sType == rhs.sType ) @@ -12487,11 +12966,16 @@ public: struct PhysicalDeviceIDProperties { - operator const VkPhysicalDeviceIDProperties&() const + operator VkPhysicalDeviceIDProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceIDProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceIDProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -12569,11 +13053,16 @@ public: return *this; } - operator const VkExportMemoryWin32HandleInfoKHR&() const + operator VkExportMemoryWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkExportMemoryWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportMemoryWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12603,11 +13092,16 @@ public: #ifdef VK_USE_PLATFORM_WIN32_KHR struct MemoryWin32HandlePropertiesKHR { - operator const VkMemoryWin32HandlePropertiesKHR&() const + operator VkMemoryWin32HandlePropertiesKHR const&() const { return *reinterpret_cast(this); } + operator VkMemoryWin32HandlePropertiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryWin32HandlePropertiesKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12632,11 +13126,16 @@ public: struct MemoryFdPropertiesKHR { - operator const VkMemoryFdPropertiesKHR&() const + operator VkMemoryFdPropertiesKHR const&() const { return *reinterpret_cast(this); } + operator VkMemoryFdPropertiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryFdPropertiesKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12736,11 +13235,16 @@ public: return *this; } - operator const VkWin32KeyedMutexAcquireReleaseInfoKHR&() const + operator VkWin32KeyedMutexAcquireReleaseInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkWin32KeyedMutexAcquireReleaseInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( Win32KeyedMutexAcquireReleaseInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12821,11 +13325,16 @@ public: return *this; } - operator const VkExportSemaphoreWin32HandleInfoKHR&() const + operator VkExportSemaphoreWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkExportSemaphoreWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportSemaphoreWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12906,11 +13415,16 @@ public: return *this; } - operator const VkD3D12FenceSubmitInfoKHR&() const + operator VkD3D12FenceSubmitInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkD3D12FenceSubmitInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( D3D12FenceSubmitInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -12985,11 +13499,16 @@ public: return *this; } - operator const VkExportFenceWin32HandleInfoKHR&() const + operator VkExportFenceWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkExportFenceWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportFenceWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -13061,11 +13580,16 @@ public: return *this; } - operator const VkPhysicalDeviceMultiviewFeatures&() const + operator VkPhysicalDeviceMultiviewFeatures const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceMultiviewFeatures &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceMultiviewFeatures const& rhs ) const { return ( sType == rhs.sType ) @@ -13095,11 +13619,16 @@ public: struct PhysicalDeviceMultiviewProperties { - operator const VkPhysicalDeviceMultiviewProperties&() const + operator VkPhysicalDeviceMultiviewProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceMultiviewProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceMultiviewProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -13194,11 +13723,16 @@ public: return *this; } - operator const VkRenderPassMultiviewCreateInfo&() const + operator VkRenderPassMultiviewCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkRenderPassMultiviewCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( RenderPassMultiviewCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13277,11 +13811,16 @@ public: return *this; } - operator const VkBindBufferMemoryInfo&() const + operator VkBindBufferMemoryInfo const&() const { return *reinterpret_cast(this); } + operator VkBindBufferMemoryInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BindBufferMemoryInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13346,11 +13885,16 @@ public: return *this; } - operator const VkBindBufferMemoryDeviceGroupInfo&() const + operator VkBindBufferMemoryDeviceGroupInfo const&() const { return *reinterpret_cast(this); } + operator VkBindBufferMemoryDeviceGroupInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BindBufferMemoryDeviceGroupInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13421,11 +13965,16 @@ public: return *this; } - operator const VkBindImageMemoryInfo&() const + operator VkBindImageMemoryInfo const&() const { return *reinterpret_cast(this); } + operator VkBindImageMemoryInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BindImageMemoryInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13506,11 +14055,16 @@ public: return *this; } - operator const VkBindImageMemoryDeviceGroupInfo&() const + operator VkBindImageMemoryDeviceGroupInfo const&() const { return *reinterpret_cast(this); } + operator VkBindImageMemoryDeviceGroupInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BindImageMemoryDeviceGroupInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13585,11 +14139,16 @@ public: return *this; } - operator const VkDeviceGroupRenderPassBeginInfo&() const + operator VkDeviceGroupRenderPassBeginInfo const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupRenderPassBeginInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupRenderPassBeginInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13646,11 +14205,16 @@ public: return *this; } - operator const VkDeviceGroupCommandBufferBeginInfo&() const + operator VkDeviceGroupCommandBufferBeginInfo const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupCommandBufferBeginInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupCommandBufferBeginInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13743,11 +14307,16 @@ public: return *this; } - operator const VkDeviceGroupSubmitInfo&() const + operator VkDeviceGroupSubmitInfo const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupSubmitInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupSubmitInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13818,11 +14387,16 @@ public: return *this; } - operator const VkDeviceGroupBindSparseInfo&() const + operator VkDeviceGroupBindSparseInfo const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupBindSparseInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupBindSparseInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -13877,11 +14451,16 @@ public: return *this; } - operator const VkImageSwapchainCreateInfoKHR&() const + operator VkImageSwapchainCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImageSwapchainCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageSwapchainCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -13940,11 +14519,16 @@ public: return *this; } - operator const VkBindImageMemorySwapchainInfoKHR&() const + operator VkBindImageMemorySwapchainInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkBindImageMemorySwapchainInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( BindImageMemorySwapchainInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -14029,11 +14613,16 @@ public: return *this; } - operator const VkAcquireNextImageInfoKHR&() const + operator VkAcquireNextImageInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkAcquireNextImageInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( AcquireNextImageInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -14148,11 +14737,16 @@ public: return *this; } - operator const VkHdrMetadataEXT&() const + operator VkHdrMetadataEXT const&() const { return *reinterpret_cast(this); } + operator VkHdrMetadataEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( HdrMetadataEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -14225,11 +14819,16 @@ public: return *this; } - operator const VkPresentTimesInfoGOOGLE&() const + operator VkPresentTimesInfoGOOGLE const&() const { return *reinterpret_cast(this); } + operator VkPresentTimesInfoGOOGLE &() + { + return *reinterpret_cast(this); + } + bool operator==( PresentTimesInfoGOOGLE const& rhs ) const { return ( sType == rhs.sType ) @@ -14291,11 +14890,16 @@ public: return *this; } - operator const VkIOSSurfaceCreateInfoMVK&() const + operator VkIOSSurfaceCreateInfoMVK const&() const { return *reinterpret_cast(this); } + operator VkIOSSurfaceCreateInfoMVK &() + { + return *reinterpret_cast(this); + } + bool operator==( IOSSurfaceCreateInfoMVK const& rhs ) const { return ( sType == rhs.sType ) @@ -14358,11 +14962,16 @@ public: return *this; } - operator const VkMacOSSurfaceCreateInfoMVK&() const + operator VkMacOSSurfaceCreateInfoMVK const&() const { return *reinterpret_cast(this); } + operator VkMacOSSurfaceCreateInfoMVK &() + { + return *reinterpret_cast(this); + } + bool operator==( MacOSSurfaceCreateInfoMVK const& rhs ) const { return ( sType == rhs.sType ) @@ -14432,11 +15041,16 @@ public: return *this; } - operator const VkPipelineViewportWScalingStateCreateInfoNV&() const + operator VkPipelineViewportWScalingStateCreateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkPipelineViewportWScalingStateCreateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineViewportWScalingStateCreateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -14491,11 +15105,16 @@ public: return *this; } - operator const VkPhysicalDeviceDiscardRectanglePropertiesEXT&() const + operator VkPhysicalDeviceDiscardRectanglePropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceDiscardRectanglePropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceDiscardRectanglePropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -14519,11 +15138,16 @@ public: struct PhysicalDeviceMultiviewPerViewAttributesPropertiesNVX { - operator const VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX&() const + operator VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceMultiviewPerViewAttributesPropertiesNVX const& rhs ) const { return ( sType == rhs.sType ) @@ -14574,11 +15198,16 @@ public: return *this; } - operator const VkPhysicalDeviceSurfaceInfo2KHR&() const + operator VkPhysicalDeviceSurfaceInfo2KHR const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceSurfaceInfo2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceSurfaceInfo2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -14602,11 +15231,16 @@ public: struct DisplayPlaneProperties2KHR { - operator const VkDisplayPlaneProperties2KHR&() const + operator VkDisplayPlaneProperties2KHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayPlaneProperties2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPlaneProperties2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -14630,11 +15264,16 @@ public: struct DisplayModeProperties2KHR { - operator const VkDisplayModeProperties2KHR&() const + operator VkDisplayModeProperties2KHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayModeProperties2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayModeProperties2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -14693,11 +15332,16 @@ public: return *this; } - operator const VkDisplayPlaneInfo2KHR&() const + operator VkDisplayPlaneInfo2KHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayPlaneInfo2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPlaneInfo2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -14774,11 +15418,16 @@ public: return *this; } - operator const VkPhysicalDevice16BitStorageFeatures&() const + operator VkPhysicalDevice16BitStorageFeatures const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDevice16BitStorageFeatures &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDevice16BitStorageFeatures const& rhs ) const { return ( sType == rhs.sType ) @@ -14837,11 +15486,16 @@ public: return *this; } - operator const VkBufferMemoryRequirementsInfo2&() const + operator VkBufferMemoryRequirementsInfo2 const&() const { return *reinterpret_cast(this); } + operator VkBufferMemoryRequirementsInfo2 &() + { + return *reinterpret_cast(this); + } + bool operator==( BufferMemoryRequirementsInfo2 const& rhs ) const { return ( sType == rhs.sType ) @@ -14894,11 +15548,16 @@ public: return *this; } - operator const VkImageMemoryRequirementsInfo2&() const + operator VkImageMemoryRequirementsInfo2 const&() const { return *reinterpret_cast(this); } + operator VkImageMemoryRequirementsInfo2 &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageMemoryRequirementsInfo2 const& rhs ) const { return ( sType == rhs.sType ) @@ -14951,11 +15610,16 @@ public: return *this; } - operator const VkImageSparseMemoryRequirementsInfo2&() const + operator VkImageSparseMemoryRequirementsInfo2 const&() const { return *reinterpret_cast(this); } + operator VkImageSparseMemoryRequirementsInfo2 &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageSparseMemoryRequirementsInfo2 const& rhs ) const { return ( sType == rhs.sType ) @@ -14981,11 +15645,16 @@ public: struct MemoryRequirements2 { - operator const VkMemoryRequirements2&() const + operator VkMemoryRequirements2 const&() const { return *reinterpret_cast(this); } + operator VkMemoryRequirements2 &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryRequirements2 const& rhs ) const { return ( sType == rhs.sType ) @@ -15011,11 +15680,16 @@ public: struct MemoryDedicatedRequirements { - operator const VkMemoryDedicatedRequirements&() const + operator VkMemoryDedicatedRequirements const&() const { return *reinterpret_cast(this); } + operator VkMemoryDedicatedRequirements &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryDedicatedRequirements const& rhs ) const { return ( sType == rhs.sType ) @@ -15078,11 +15752,16 @@ public: return *this; } - operator const VkMemoryDedicatedAllocateInfo&() const + operator VkMemoryDedicatedAllocateInfo const&() const { return *reinterpret_cast(this); } + operator VkMemoryDedicatedAllocateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryDedicatedAllocateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -15137,11 +15816,16 @@ public: return *this; } - operator const VkSamplerYcbcrConversionInfo&() const + operator VkSamplerYcbcrConversionInfo const&() const { return *reinterpret_cast(this); } + operator VkSamplerYcbcrConversionInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SamplerYcbcrConversionInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -15194,11 +15878,16 @@ public: return *this; } - operator const VkPhysicalDeviceSamplerYcbcrConversionFeatures&() const + operator VkPhysicalDeviceSamplerYcbcrConversionFeatures const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceSamplerYcbcrConversionFeatures &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceSamplerYcbcrConversionFeatures const& rhs ) const { return ( sType == rhs.sType ) @@ -15224,11 +15913,16 @@ public: struct SamplerYcbcrConversionImageFormatProperties { - operator const VkSamplerYcbcrConversionImageFormatProperties&() const + operator VkSamplerYcbcrConversionImageFormatProperties const&() const { return *reinterpret_cast(this); } + operator VkSamplerYcbcrConversionImageFormatProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( SamplerYcbcrConversionImageFormatProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -15254,11 +15948,16 @@ public: struct TextureLODGatherFormatPropertiesAMD { - operator const VkTextureLODGatherFormatPropertiesAMD&() const + operator VkTextureLODGatherFormatPropertiesAMD const&() const { return *reinterpret_cast(this); } + operator VkTextureLODGatherFormatPropertiesAMD &() + { + return *reinterpret_cast(this); + } + bool operator==( TextureLODGatherFormatPropertiesAMD const& rhs ) const { return ( sType == rhs.sType ) @@ -15309,11 +16008,16 @@ public: return *this; } - operator const VkProtectedSubmitInfo&() const + operator VkProtectedSubmitInfo const&() const { return *reinterpret_cast(this); } + operator VkProtectedSubmitInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ProtectedSubmitInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -15364,11 +16068,16 @@ public: return *this; } - operator const VkPhysicalDeviceProtectedMemoryFeatures&() const + operator VkPhysicalDeviceProtectedMemoryFeatures const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceProtectedMemoryFeatures &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceProtectedMemoryFeatures const& rhs ) const { return ( sType == rhs.sType ) @@ -15419,11 +16128,16 @@ public: return *this; } - operator const VkPhysicalDeviceProtectedMemoryProperties&() const + operator VkPhysicalDeviceProtectedMemoryProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceProtectedMemoryProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceProtectedMemoryProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -15490,11 +16204,16 @@ public: return *this; } - operator const VkPipelineCoverageToColorStateCreateInfoNV&() const + operator VkPipelineCoverageToColorStateCreateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkPipelineCoverageToColorStateCreateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineCoverageToColorStateCreateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -15522,11 +16241,16 @@ public: struct PhysicalDeviceSamplerFilterMinmaxPropertiesEXT { - operator const VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT&() const + operator VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceSamplerFilterMinmaxPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -15552,11 +16276,16 @@ public: struct MultisamplePropertiesEXT { - operator const VkMultisamplePropertiesEXT&() const + operator VkMultisamplePropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkMultisamplePropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( MultisamplePropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -15607,11 +16336,16 @@ public: return *this; } - operator const VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT&() const + operator VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceBlendOperationAdvancedFeaturesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -15635,11 +16369,16 @@ public: struct PhysicalDeviceBlendOperationAdvancedPropertiesEXT { - operator const VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT&() const + operator VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceBlendOperationAdvancedPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -15708,11 +16447,16 @@ public: return *this; } - operator const VkImageFormatListCreateInfoKHR&() const + operator VkImageFormatListCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImageFormatListCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageFormatListCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -15781,11 +16525,16 @@ public: return *this; } - operator const VkValidationCacheCreateInfoEXT&() const + operator VkValidationCacheCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkValidationCacheCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( ValidationCacheCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -15840,11 +16589,16 @@ public: return *this; } - operator const VkShaderModuleValidationCacheCreateInfoEXT&() const + operator VkShaderModuleValidationCacheCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkShaderModuleValidationCacheCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( ShaderModuleValidationCacheCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -15868,11 +16622,16 @@ public: struct PhysicalDeviceMaintenance3Properties { - operator const VkPhysicalDeviceMaintenance3Properties&() const + operator VkPhysicalDeviceMaintenance3Properties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceMaintenance3Properties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceMaintenance3Properties const& rhs ) const { return ( sType == rhs.sType ) @@ -15900,11 +16659,16 @@ public: struct DescriptorSetLayoutSupport { - operator const VkDescriptorSetLayoutSupport&() const + operator VkDescriptorSetLayoutSupport const&() const { return *reinterpret_cast(this); } + operator VkDescriptorSetLayoutSupport &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorSetLayoutSupport const& rhs ) const { return ( sType == rhs.sType ) @@ -15957,11 +16721,16 @@ public: return *this; } - operator const VkPhysicalDeviceShaderDrawParameterFeatures&() const + operator VkPhysicalDeviceShaderDrawParameterFeatures const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceShaderDrawParameterFeatures &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceShaderDrawParameterFeatures const& rhs ) const { return ( sType == rhs.sType ) @@ -16020,11 +16789,16 @@ public: return *this; } - operator const VkDebugUtilsLabelEXT&() const + operator VkDebugUtilsLabelEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugUtilsLabelEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugUtilsLabelEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16077,11 +16851,16 @@ public: return *this; } - operator const VkMemoryHostPointerPropertiesEXT&() const + operator VkMemoryHostPointerPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkMemoryHostPointerPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryHostPointerPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16132,11 +16911,16 @@ public: return *this; } - operator const VkPhysicalDeviceExternalMemoryHostPropertiesEXT&() const + operator VkPhysicalDeviceExternalMemoryHostPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceExternalMemoryHostPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceExternalMemoryHostPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16251,11 +17035,16 @@ public: return *this; } - operator const VkPhysicalDeviceConservativeRasterizationPropertiesEXT&() const + operator VkPhysicalDeviceConservativeRasterizationPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceConservativeRasterizationPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceConservativeRasterizationPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16295,11 +17084,16 @@ public: struct PhysicalDeviceShaderCorePropertiesAMD { - operator const VkPhysicalDeviceShaderCorePropertiesAMD&() const + operator VkPhysicalDeviceShaderCorePropertiesAMD const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceShaderCorePropertiesAMD &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceShaderCorePropertiesAMD const& rhs ) const { return ( sType == rhs.sType ) @@ -16528,11 +17322,16 @@ public: return *this; } - operator const VkPhysicalDeviceDescriptorIndexingFeaturesEXT&() const + operator VkPhysicalDeviceDescriptorIndexingFeaturesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceDescriptorIndexingFeaturesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceDescriptorIndexingFeaturesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16594,11 +17393,16 @@ public: struct PhysicalDeviceDescriptorIndexingPropertiesEXT { - operator const VkPhysicalDeviceDescriptorIndexingPropertiesEXT&() const + operator VkPhysicalDeviceDescriptorIndexingPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceDescriptorIndexingPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceDescriptorIndexingPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16701,11 +17505,16 @@ public: return *this; } - operator const VkDescriptorSetVariableDescriptorCountAllocateInfoEXT&() const + operator VkDescriptorSetVariableDescriptorCountAllocateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDescriptorSetVariableDescriptorCountAllocateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorSetVariableDescriptorCountAllocateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16731,11 +17540,16 @@ public: struct DescriptorSetVariableDescriptorCountLayoutSupportEXT { - operator const VkDescriptorSetVariableDescriptorCountLayoutSupportEXT&() const + operator VkDescriptorSetVariableDescriptorCountLayoutSupportEXT const&() const { return *reinterpret_cast(this); } + operator VkDescriptorSetVariableDescriptorCountLayoutSupportEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorSetVariableDescriptorCountLayoutSupportEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16779,11 +17593,16 @@ public: return *this; } - operator const VkSubpassEndInfoKHR&() const + operator VkSubpassEndInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkSubpassEndInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SubpassEndInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -16840,11 +17659,16 @@ public: return *this; } - operator const VkPipelineVertexInputDivisorStateCreateInfoEXT&() const + operator VkPipelineVertexInputDivisorStateCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkPipelineVertexInputDivisorStateCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineVertexInputDivisorStateCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16897,11 +17721,16 @@ public: return *this; } - operator const VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT&() const + operator VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceVertexAttributeDivisorPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -16953,11 +17782,16 @@ public: return *this; } - operator const VkImportAndroidHardwareBufferInfoANDROID&() const + operator VkImportAndroidHardwareBufferInfoANDROID const&() const { return *reinterpret_cast(this); } + operator VkImportAndroidHardwareBufferInfoANDROID &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportAndroidHardwareBufferInfoANDROID const& rhs ) const { return ( sType == rhs.sType ) @@ -16983,11 +17817,16 @@ public: #ifdef VK_USE_PLATFORM_ANDROID_ANDROID struct AndroidHardwareBufferUsageANDROID { - operator const VkAndroidHardwareBufferUsageANDROID&() const + operator VkAndroidHardwareBufferUsageANDROID const&() const { return *reinterpret_cast(this); } + operator VkAndroidHardwareBufferUsageANDROID &() + { + return *reinterpret_cast(this); + } + bool operator==( AndroidHardwareBufferUsageANDROID const& rhs ) const { return ( sType == rhs.sType ) @@ -17013,11 +17852,16 @@ public: #ifdef VK_USE_PLATFORM_ANDROID_ANDROID struct AndroidHardwareBufferPropertiesANDROID { - operator const VkAndroidHardwareBufferPropertiesANDROID&() const + operator VkAndroidHardwareBufferPropertiesANDROID const&() const { return *reinterpret_cast(this); } + operator VkAndroidHardwareBufferPropertiesANDROID &() + { + return *reinterpret_cast(this); + } + bool operator==( AndroidHardwareBufferPropertiesANDROID const& rhs ) const { return ( sType == rhs.sType ) @@ -17072,11 +17916,16 @@ public: return *this; } - operator const VkMemoryGetAndroidHardwareBufferInfoANDROID&() const + operator VkMemoryGetAndroidHardwareBufferInfoANDROID const&() const { return *reinterpret_cast(this); } + operator VkMemoryGetAndroidHardwareBufferInfoANDROID &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryGetAndroidHardwareBufferInfoANDROID const& rhs ) const { return ( sType == rhs.sType ) @@ -17128,11 +17977,16 @@ public: return *this; } - operator const VkCommandBufferInheritanceConditionalRenderingInfoEXT&() const + operator VkCommandBufferInheritanceConditionalRenderingInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkCommandBufferInheritanceConditionalRenderingInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( CommandBufferInheritanceConditionalRenderingInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -17184,11 +18038,16 @@ public: return *this; } - operator const VkExternalFormatANDROID&() const + operator VkExternalFormatANDROID const&() const { return *reinterpret_cast(this); } + operator VkExternalFormatANDROID &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalFormatANDROID const& rhs ) const { return ( sType == rhs.sType ) @@ -17256,11 +18115,16 @@ public: return *this; } - operator const VkPhysicalDevice8BitStorageFeaturesKHR&() const + operator VkPhysicalDevice8BitStorageFeaturesKHR const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDevice8BitStorageFeaturesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDevice8BitStorageFeaturesKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -17323,11 +18187,16 @@ public: return *this; } - operator const VkPhysicalDeviceConditionalRenderingFeaturesEXT&() const + operator VkPhysicalDeviceConditionalRenderingFeaturesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceConditionalRenderingFeaturesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceConditionalRenderingFeaturesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -17386,11 +18255,16 @@ public: return *this; } - operator const VkSubpassBeginInfoKHR&() const + operator VkSubpassBeginInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkSubpassBeginInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SubpassBeginInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -17481,11 +18355,16 @@ public: return *this; } - operator const VkPresentInfoKHR&() const + operator VkPresentInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkPresentInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( PresentInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -17578,11 +18457,16 @@ public: return *this; } - operator const VkPipelineDynamicStateCreateInfo&() const + operator VkPipelineDynamicStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineDynamicStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineDynamicStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -17700,11 +18584,16 @@ public: return *this; } - operator const VkDescriptorUpdateTemplateCreateInfo&() const + operator VkDescriptorUpdateTemplateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkDescriptorUpdateTemplateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorUpdateTemplateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -17830,11 +18719,16 @@ public: return *this; } - operator const VkDebugUtilsObjectNameInfoEXT&() const + operator VkDebugUtilsObjectNameInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugUtilsObjectNameInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugUtilsObjectNameInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -17921,11 +18815,16 @@ public: return *this; } - operator const VkDebugUtilsObjectTagInfoEXT&() const + operator VkDebugUtilsObjectTagInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugUtilsObjectTagInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugUtilsObjectTagInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -18056,11 +18955,16 @@ public: return *this; } - operator const VkDebugUtilsMessengerCallbackDataEXT&() const + operator VkDebugUtilsMessengerCallbackDataEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugUtilsMessengerCallbackDataEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugUtilsMessengerCallbackDataEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -18131,11 +19035,16 @@ public: struct QueueFamilyProperties { - operator const VkQueueFamilyProperties&() const + operator VkQueueFamilyProperties const&() const { return *reinterpret_cast(this); } + operator VkQueueFamilyProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( QueueFamilyProperties const& rhs ) const { return ( queueFlags == rhs.queueFlags ) @@ -18158,11 +19067,16 @@ public: struct QueueFamilyProperties2 { - operator const VkQueueFamilyProperties2&() const + operator VkQueueFamilyProperties2 const&() const { return *reinterpret_cast(this); } + operator VkQueueFamilyProperties2 &() + { + return *reinterpret_cast(this); + } + bool operator==( QueueFamilyProperties2 const& rhs ) const { return ( sType == rhs.sType ) @@ -18264,11 +19178,16 @@ public: return *this; } - operator const VkDeviceQueueCreateInfo&() const + operator VkDeviceQueueCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkDeviceQueueCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceQueueCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -18381,11 +19300,16 @@ public: return *this; } - operator const VkDeviceCreateInfo&() const + operator VkDeviceCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkDeviceCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -18466,11 +19390,16 @@ public: return *this; } - operator const VkDeviceQueueInfo2&() const + operator VkDeviceQueueInfo2 const&() const { return *reinterpret_cast(this); } + operator VkDeviceQueueInfo2 &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceQueueInfo2 const& rhs ) const { return ( sType == rhs.sType ) @@ -18528,11 +19457,16 @@ public: struct MemoryType { - operator const VkMemoryType&() const + operator VkMemoryType const&() const { return *reinterpret_cast(this); } + operator VkMemoryType &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryType const& rhs ) const { return ( propertyFlags == rhs.propertyFlags ) @@ -18578,11 +19512,16 @@ public: struct MemoryHeap { - operator const VkMemoryHeap&() const + operator VkMemoryHeap const&() const { return *reinterpret_cast(this); } + operator VkMemoryHeap &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryHeap const& rhs ) const { return ( size == rhs.size ) @@ -18601,11 +19540,16 @@ public: struct PhysicalDeviceMemoryProperties { - operator const VkPhysicalDeviceMemoryProperties&() const + operator VkPhysicalDeviceMemoryProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceMemoryProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceMemoryProperties const& rhs ) const { return ( memoryTypeCount == rhs.memoryTypeCount ) @@ -18628,11 +19572,16 @@ public: struct PhysicalDeviceMemoryProperties2 { - operator const VkPhysicalDeviceMemoryProperties2&() const + operator VkPhysicalDeviceMemoryProperties2 const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceMemoryProperties2 &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceMemoryProperties2 const& rhs ) const { return ( sType == rhs.sType ) @@ -18738,11 +19687,16 @@ public: return *this; } - operator const VkMemoryBarrier&() const + operator VkMemoryBarrier const&() const { return *reinterpret_cast(this); } + operator VkMemoryBarrier &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryBarrier const& rhs ) const { return ( sType == rhs.sType ) @@ -18843,11 +19797,16 @@ public: return *this; } - operator const VkBufferMemoryBarrier&() const + operator VkBufferMemoryBarrier const&() const { return *reinterpret_cast(this); } + operator VkBufferMemoryBarrier &() + { + return *reinterpret_cast(this); + } + bool operator==( BufferMemoryBarrier const& rhs ) const { return ( sType == rhs.sType ) @@ -19012,11 +19971,16 @@ public: return *this; } - operator const VkBufferCreateInfo&() const + operator VkBufferCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkBufferCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BufferCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -19135,11 +20099,16 @@ public: return *this; } - operator const VkDescriptorSetLayoutBinding&() const + operator VkDescriptorSetLayoutBinding const&() const { return *reinterpret_cast(this); } + operator VkDescriptorSetLayoutBinding &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorSetLayoutBinding const& rhs ) const { return ( binding == rhs.binding ) @@ -19223,11 +20192,16 @@ public: return *this; } - operator const VkPipelineShaderStageCreateInfo&() const + operator VkPipelineShaderStageCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineShaderStageCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineShaderStageCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -19296,11 +20270,16 @@ public: return *this; } - operator const VkPushConstantRange&() const + operator VkPushConstantRange const&() const { return *reinterpret_cast(this); } + operator VkPushConstantRange &() + { + return *reinterpret_cast(this); + } + bool operator==( PushConstantRange const& rhs ) const { return ( stageFlags == rhs.stageFlags ) @@ -19380,11 +20359,16 @@ public: return *this; } - operator const VkPipelineLayoutCreateInfo&() const + operator VkPipelineLayoutCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineLayoutCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineLayoutCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -19416,11 +20400,16 @@ public: struct ShaderStatisticsInfoAMD { - operator const VkShaderStatisticsInfoAMD&() const + operator VkShaderStatisticsInfoAMD const&() const { return *reinterpret_cast(this); } + operator VkShaderStatisticsInfoAMD &() + { + return *reinterpret_cast(this); + } + bool operator==( ShaderStatisticsInfoAMD const& rhs ) const { return ( shaderStageMask == rhs.shaderStageMask ) @@ -19481,11 +20470,16 @@ public: struct SharedPresentSurfaceCapabilitiesKHR { - operator const VkSharedPresentSurfaceCapabilitiesKHR&() const + operator VkSharedPresentSurfaceCapabilitiesKHR const&() const { return *reinterpret_cast(this); } + operator VkSharedPresentSurfaceCapabilitiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SharedPresentSurfaceCapabilitiesKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -19536,11 +20530,16 @@ public: return *this; } - operator const VkImageViewUsageCreateInfo&() const + operator VkImageViewUsageCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkImageViewUsageCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageViewUsageCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -19668,11 +20667,16 @@ public: return *this; } - operator const VkPhysicalDeviceImageFormatInfo2&() const + operator VkPhysicalDeviceImageFormatInfo2 const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceImageFormatInfo2 &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceImageFormatInfo2 const& rhs ) const { return ( sType == rhs.sType ) @@ -19796,11 +20800,16 @@ public: return *this; } - operator const VkComputePipelineCreateInfo&() const + operator VkComputePipelineCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkComputePipelineCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ComputePipelineCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -19937,11 +20946,16 @@ public: return *this; } - operator const VkPipelineColorBlendAttachmentState&() const + operator VkPipelineColorBlendAttachmentState const&() const { return *reinterpret_cast(this); } + operator VkPipelineColorBlendAttachmentState &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineColorBlendAttachmentState const& rhs ) const { return ( blendEnable == rhs.blendEnable ) @@ -20039,11 +21053,16 @@ public: return *this; } - operator const VkPipelineColorBlendStateCreateInfo&() const + operator VkPipelineColorBlendStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineColorBlendStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineColorBlendStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -20129,11 +21148,16 @@ public: return *this; } - operator const VkFenceCreateInfo&() const + operator VkFenceCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkFenceCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( FenceCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -20214,11 +21238,16 @@ public: struct FormatProperties { - operator const VkFormatProperties&() const + operator VkFormatProperties const&() const { return *reinterpret_cast(this); } + operator VkFormatProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( FormatProperties const& rhs ) const { return ( linearTilingFeatures == rhs.linearTilingFeatures ) @@ -20239,11 +21268,16 @@ public: struct FormatProperties2 { - operator const VkFormatProperties2&() const + operator VkFormatProperties2 const&() const { return *reinterpret_cast(this); } + operator VkFormatProperties2 &() + { + return *reinterpret_cast(this); + } + bool operator==( FormatProperties2 const& rhs ) const { return ( sType == rhs.sType ) @@ -20451,11 +21485,16 @@ public: return *this; } - operator const VkCommandBufferInheritanceInfo&() const + operator VkCommandBufferInheritanceInfo const&() const { return *reinterpret_cast(this); } + operator VkCommandBufferInheritanceInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( CommandBufferInheritanceInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -20524,11 +21563,16 @@ public: return *this; } - operator const VkCommandBufferBeginInfo&() const + operator VkCommandBufferBeginInfo const&() const { return *reinterpret_cast(this); } + operator VkCommandBufferBeginInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( CommandBufferBeginInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -20605,11 +21649,16 @@ public: return *this; } - operator const VkQueryPoolCreateInfo&() const + operator VkQueryPoolCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkQueryPoolCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( QueryPoolCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -20710,11 +21759,16 @@ public: return *this; } - operator const VkImageSubresource&() const + operator VkImageSubresource const&() const { return *reinterpret_cast(this); } + operator VkImageSubresource &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageSubresource const& rhs ) const { return ( aspectMask == rhs.aspectMask ) @@ -20780,11 +21834,16 @@ public: return *this; } - operator const VkImageSubresourceLayers&() const + operator VkImageSubresourceLayers const&() const { return *reinterpret_cast(this); } + operator VkImageSubresourceLayers &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageSubresourceLayers const& rhs ) const { return ( aspectMask == rhs.aspectMask ) @@ -20860,11 +21919,16 @@ public: return *this; } - operator const VkImageSubresourceRange&() const + operator VkImageSubresourceRange const&() const { return *reinterpret_cast(this); } + operator VkImageSubresourceRange &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageSubresourceRange const& rhs ) const { return ( aspectMask == rhs.aspectMask ) @@ -20972,11 +22036,16 @@ public: return *this; } - operator const VkImageMemoryBarrier&() const + operator VkImageMemoryBarrier const&() const { return *reinterpret_cast(this); } + operator VkImageMemoryBarrier &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageMemoryBarrier const& rhs ) const { return ( sType == rhs.sType ) @@ -21081,11 +22150,16 @@ public: return *this; } - operator const VkImageViewCreateInfo&() const + operator VkImageViewCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkImageViewCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageViewCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -21172,11 +22246,16 @@ public: return *this; } - operator const VkImageCopy&() const + operator VkImageCopy const&() const { return *reinterpret_cast(this); } + operator VkImageCopy &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageCopy const& rhs ) const { return ( srcSubresource == rhs.srcSubresource ) @@ -21246,11 +22325,16 @@ public: return *this; } - operator const VkImageBlit&() const + operator VkImageBlit const&() const { return *reinterpret_cast(this); } + operator VkImageBlit &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageBlit const& rhs ) const { return ( srcSubresource == rhs.srcSubresource ) @@ -21334,11 +22418,16 @@ public: return *this; } - operator const VkBufferImageCopy&() const + operator VkBufferImageCopy const&() const { return *reinterpret_cast(this); } + operator VkBufferImageCopy &() + { + return *reinterpret_cast(this); + } + bool operator==( BufferImageCopy const& rhs ) const { return ( bufferOffset == rhs.bufferOffset ) @@ -21418,11 +22507,16 @@ public: return *this; } - operator const VkImageResolve&() const + operator VkImageResolve const&() const { return *reinterpret_cast(this); } + operator VkImageResolve &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageResolve const& rhs ) const { return ( srcSubresource == rhs.srcSubresource ) @@ -21484,11 +22578,16 @@ public: return *this; } - operator const VkClearAttachment&() const + operator VkClearAttachment const&() const { return *reinterpret_cast(this); } + operator VkClearAttachment &() + { + return *reinterpret_cast(this); + } + ImageAspectFlags aspectMask; uint32_t colorAttachment; ClearValue clearValue; @@ -21534,11 +22633,16 @@ public: return *this; } - operator const VkInputAttachmentAspectReference&() const + operator VkInputAttachmentAspectReference const&() const { return *reinterpret_cast(this); } + operator VkInputAttachmentAspectReference &() + { + return *reinterpret_cast(this); + } + bool operator==( InputAttachmentAspectReference const& rhs ) const { return ( subpass == rhs.subpass ) @@ -21596,11 +22700,16 @@ public: return *this; } - operator const VkRenderPassInputAttachmentAspectCreateInfo&() const + operator VkRenderPassInputAttachmentAspectCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkRenderPassInputAttachmentAspectCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( RenderPassInputAttachmentAspectCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -21655,11 +22764,16 @@ public: return *this; } - operator const VkBindImagePlaneMemoryInfo&() const + operator VkBindImagePlaneMemoryInfo const&() const { return *reinterpret_cast(this); } + operator VkBindImagePlaneMemoryInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BindImagePlaneMemoryInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -21712,11 +22826,16 @@ public: return *this; } - operator const VkImagePlaneMemoryRequirementsInfo&() const + operator VkImagePlaneMemoryRequirementsInfo const&() const { return *reinterpret_cast(this); } + operator VkImagePlaneMemoryRequirementsInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ImagePlaneMemoryRequirementsInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -21785,11 +22904,16 @@ public: return *this; } - operator const VkAttachmentReference2KHR&() const + operator VkAttachmentReference2KHR const&() const { return *reinterpret_cast(this); } + operator VkAttachmentReference2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( AttachmentReference2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -21844,11 +22968,16 @@ public: struct SparseImageFormatProperties { - operator const VkSparseImageFormatProperties&() const + operator VkSparseImageFormatProperties const&() const { return *reinterpret_cast(this); } + operator VkSparseImageFormatProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseImageFormatProperties const& rhs ) const { return ( aspectMask == rhs.aspectMask ) @@ -21869,11 +22998,16 @@ public: struct SparseImageMemoryRequirements { - operator const VkSparseImageMemoryRequirements&() const + operator VkSparseImageMemoryRequirements const&() const { return *reinterpret_cast(this); } + operator VkSparseImageMemoryRequirements &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseImageMemoryRequirements const& rhs ) const { return ( formatProperties == rhs.formatProperties ) @@ -21898,11 +23032,16 @@ public: struct SparseImageFormatProperties2 { - operator const VkSparseImageFormatProperties2&() const + operator VkSparseImageFormatProperties2 const&() const { return *reinterpret_cast(this); } + operator VkSparseImageFormatProperties2 &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseImageFormatProperties2 const& rhs ) const { return ( sType == rhs.sType ) @@ -21928,11 +23067,16 @@ public: struct SparseImageMemoryRequirements2 { - operator const VkSparseImageMemoryRequirements2&() const + operator VkSparseImageMemoryRequirements2 const&() const { return *reinterpret_cast(this); } + operator VkSparseImageMemoryRequirements2 &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseImageMemoryRequirements2 const& rhs ) const { return ( sType == rhs.sType ) @@ -22036,11 +23180,16 @@ public: return *this; } - operator const VkSparseMemoryBind&() const + operator VkSparseMemoryBind const&() const { return *reinterpret_cast(this); } + operator VkSparseMemoryBind &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseMemoryBind const& rhs ) const { return ( resourceOffset == rhs.resourceOffset ) @@ -22126,11 +23275,16 @@ public: return *this; } - operator const VkSparseImageMemoryBind&() const + operator VkSparseImageMemoryBind const&() const { return *reinterpret_cast(this); } + operator VkSparseImageMemoryBind &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseImageMemoryBind const& rhs ) const { return ( subresource == rhs.subresource ) @@ -22194,11 +23348,16 @@ public: return *this; } - operator const VkSparseBufferMemoryBindInfo&() const + operator VkSparseBufferMemoryBindInfo const&() const { return *reinterpret_cast(this); } + operator VkSparseBufferMemoryBindInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseBufferMemoryBindInfo const& rhs ) const { return ( buffer == rhs.buffer ) @@ -22256,11 +23415,16 @@ public: return *this; } - operator const VkSparseImageOpaqueMemoryBindInfo&() const + operator VkSparseImageOpaqueMemoryBindInfo const&() const { return *reinterpret_cast(this); } + operator VkSparseImageOpaqueMemoryBindInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseImageOpaqueMemoryBindInfo const& rhs ) const { return ( image == rhs.image ) @@ -22318,11 +23482,16 @@ public: return *this; } - operator const VkSparseImageMemoryBindInfo&() const + operator VkSparseImageMemoryBindInfo const&() const { return *reinterpret_cast(this); } + operator VkSparseImageMemoryBindInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SparseImageMemoryBindInfo const& rhs ) const { return ( image == rhs.image ) @@ -22442,11 +23611,16 @@ public: return *this; } - operator const VkBindSparseInfo&() const + operator VkBindSparseInfo const&() const { return *reinterpret_cast(this); } + operator VkBindSparseInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( BindSparseInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -22531,11 +23705,16 @@ public: struct QueueFamilyCheckpointPropertiesNV { - operator const VkQueueFamilyCheckpointPropertiesNV&() const + operator VkQueueFamilyCheckpointPropertiesNV const&() const { return *reinterpret_cast(this); } + operator VkQueueFamilyCheckpointPropertiesNV &() + { + return *reinterpret_cast(this); + } + bool operator==( QueueFamilyCheckpointPropertiesNV const& rhs ) const { return ( sType == rhs.sType ) @@ -22559,11 +23738,16 @@ public: struct CheckpointDataNV { - operator const VkCheckpointDataNV&() const + operator VkCheckpointDataNV const&() const { return *reinterpret_cast(this); } + operator VkCheckpointDataNV &() + { + return *reinterpret_cast(this); + } + bool operator==( CheckpointDataNV const& rhs ) const { return ( sType == rhs.sType ) @@ -22651,11 +23835,16 @@ public: return *this; } - operator const VkCommandPoolCreateInfo&() const + operator VkCommandPoolCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkCommandPoolCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( CommandPoolCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -22762,11 +23951,16 @@ public: struct ImageFormatProperties { - operator const VkImageFormatProperties&() const + operator VkImageFormatProperties const&() const { return *reinterpret_cast(this); } + operator VkImageFormatProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageFormatProperties const& rhs ) const { return ( maxExtent == rhs.maxExtent ) @@ -22914,11 +24108,16 @@ public: return *this; } - operator const VkImageCreateInfo&() const + operator VkImageCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkImageCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -23041,11 +24240,16 @@ public: return *this; } - operator const VkPipelineMultisampleStateCreateInfo&() const + operator VkPipelineMultisampleStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineMultisampleStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineMultisampleStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -23236,11 +24440,16 @@ public: return *this; } - operator const VkGraphicsPipelineCreateInfo&() const + operator VkGraphicsPipelineCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkGraphicsPipelineCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( GraphicsPipelineCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -23296,11 +24505,16 @@ public: struct PhysicalDeviceLimits { - operator const VkPhysicalDeviceLimits&() const + operator VkPhysicalDeviceLimits const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceLimits &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceLimits const& rhs ) const { return ( maxImageDimension1D == rhs.maxImageDimension1D ) @@ -23527,11 +24741,16 @@ public: struct PhysicalDeviceProperties { - operator const VkPhysicalDeviceProperties&() const + operator VkPhysicalDeviceProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceProperties const& rhs ) const { return ( apiVersion == rhs.apiVersion ) @@ -23564,11 +24783,16 @@ public: struct PhysicalDeviceProperties2 { - operator const VkPhysicalDeviceProperties2&() const + operator VkPhysicalDeviceProperties2 const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceProperties2 &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceProperties2 const& rhs ) const { return ( sType == rhs.sType ) @@ -23594,11 +24818,16 @@ public: struct ImageFormatProperties2 { - operator const VkImageFormatProperties2&() const + operator VkImageFormatProperties2 const&() const { return *reinterpret_cast(this); } + operator VkImageFormatProperties2 &() + { + return *reinterpret_cast(this); + } + bool operator==( ImageFormatProperties2 const& rhs ) const { return ( sType == rhs.sType ) @@ -23683,11 +24912,16 @@ public: return *this; } - operator const VkPhysicalDeviceSparseImageFormatInfo2&() const + operator VkPhysicalDeviceSparseImageFormatInfo2 const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceSparseImageFormatInfo2 &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceSparseImageFormatInfo2 const& rhs ) const { return ( sType == rhs.sType ) @@ -23772,11 +25006,16 @@ public: return *this; } - operator const VkSampleLocationsInfoEXT&() const + operator VkSampleLocationsInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkSampleLocationsInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( SampleLocationsInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -23835,11 +25074,16 @@ public: return *this; } - operator const VkAttachmentSampleLocationsEXT&() const + operator VkAttachmentSampleLocationsEXT const&() const { return *reinterpret_cast(this); } + operator VkAttachmentSampleLocationsEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( AttachmentSampleLocationsEXT const& rhs ) const { return ( attachmentIndex == rhs.attachmentIndex ) @@ -23887,11 +25131,16 @@ public: return *this; } - operator const VkSubpassSampleLocationsEXT&() const + operator VkSubpassSampleLocationsEXT const&() const { return *reinterpret_cast(this); } + operator VkSubpassSampleLocationsEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( SubpassSampleLocationsEXT const& rhs ) const { return ( subpassIndex == rhs.subpassIndex ) @@ -23961,11 +25210,16 @@ public: return *this; } - operator const VkRenderPassSampleLocationsBeginInfoEXT&() const + operator VkRenderPassSampleLocationsBeginInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkRenderPassSampleLocationsBeginInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( RenderPassSampleLocationsBeginInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -24030,11 +25284,16 @@ public: return *this; } - operator const VkPipelineSampleLocationsStateCreateInfoEXT&() const + operator VkPipelineSampleLocationsStateCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkPipelineSampleLocationsStateCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineSampleLocationsStateCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -24060,11 +25319,16 @@ public: struct PhysicalDeviceSampleLocationsPropertiesEXT { - operator const VkPhysicalDeviceSampleLocationsPropertiesEXT&() const + operator VkPhysicalDeviceSampleLocationsPropertiesEXT const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceSampleLocationsPropertiesEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceSampleLocationsPropertiesEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -24206,11 +25470,16 @@ public: return *this; } - operator const VkAttachmentDescription&() const + operator VkAttachmentDescription const&() const { return *reinterpret_cast(this); } + operator VkAttachmentDescription &() + { + return *reinterpret_cast(this); + } + bool operator==( AttachmentDescription const& rhs ) const { return ( flags == rhs.flags ) @@ -24334,11 +25603,16 @@ public: return *this; } - operator const VkAttachmentDescription2KHR&() const + operator VkAttachmentDescription2KHR const&() const { return *reinterpret_cast(this); } + operator VkAttachmentDescription2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( AttachmentDescription2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -24482,11 +25756,16 @@ public: return *this; } - operator const VkDescriptorPoolCreateInfo&() const + operator VkDescriptorPoolCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkDescriptorPoolCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorPoolCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -24614,11 +25893,16 @@ public: return *this; } - operator const VkSubpassDependency&() const + operator VkSubpassDependency const&() const { return *reinterpret_cast(this); } + operator VkSubpassDependency &() + { + return *reinterpret_cast(this); + } + bool operator==( SubpassDependency const& rhs ) const { return ( srcSubpass == rhs.srcSubpass ) @@ -24730,11 +26014,16 @@ public: return *this; } - operator const VkSubpassDependency2KHR&() const + operator VkSubpassDependency2KHR const&() const { return *reinterpret_cast(this); } + operator VkSubpassDependency2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SubpassDependency2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -24802,11 +26091,16 @@ public: struct SurfaceFormatKHR { - operator const VkSurfaceFormatKHR&() const + operator VkSurfaceFormatKHR const&() const { return *reinterpret_cast(this); } + operator VkSurfaceFormatKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SurfaceFormatKHR const& rhs ) const { return ( format == rhs.format ) @@ -24825,11 +26119,16 @@ public: struct SurfaceFormat2KHR { - operator const VkSurfaceFormat2KHR&() const + operator VkSurfaceFormat2KHR const&() const { return *reinterpret_cast(this); } + operator VkSurfaceFormat2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SurfaceFormat2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -24881,11 +26180,16 @@ public: struct DisplayPlaneCapabilitiesKHR { - operator const VkDisplayPlaneCapabilitiesKHR&() const + operator VkDisplayPlaneCapabilitiesKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayPlaneCapabilitiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPlaneCapabilitiesKHR const& rhs ) const { return ( supportedAlpha == rhs.supportedAlpha ) @@ -24918,11 +26222,16 @@ public: struct DisplayPlaneCapabilities2KHR { - operator const VkDisplayPlaneCapabilities2KHR&() const + operator VkDisplayPlaneCapabilities2KHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayPlaneCapabilities2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPlaneCapabilities2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -25007,11 +26316,16 @@ public: struct DisplayPropertiesKHR { - operator const VkDisplayPropertiesKHR&() const + operator VkDisplayPropertiesKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayPropertiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPropertiesKHR const& rhs ) const { return ( display == rhs.display ) @@ -25123,11 +26437,16 @@ public: return *this; } - operator const VkDisplaySurfaceCreateInfoKHR&() const + operator VkDisplaySurfaceCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkDisplaySurfaceCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplaySurfaceCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -25165,11 +26484,16 @@ public: struct SurfaceCapabilitiesKHR { - operator const VkSurfaceCapabilitiesKHR&() const + operator VkSurfaceCapabilitiesKHR const&() const { return *reinterpret_cast(this); } + operator VkSurfaceCapabilitiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SurfaceCapabilitiesKHR const& rhs ) const { return ( minImageCount == rhs.minImageCount ) @@ -25204,11 +26528,16 @@ public: struct SurfaceCapabilities2KHR { - operator const VkSurfaceCapabilities2KHR&() const + operator VkSurfaceCapabilities2KHR const&() const { return *reinterpret_cast(this); } + operator VkSurfaceCapabilities2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SurfaceCapabilities2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -25232,11 +26561,16 @@ public: struct DisplayProperties2KHR { - operator const VkDisplayProperties2KHR&() const + operator VkDisplayProperties2KHR const&() const { return *reinterpret_cast(this); } + operator VkDisplayProperties2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayProperties2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -25332,11 +26666,16 @@ public: return *this; } - operator const VkDebugReportCallbackCreateInfoEXT&() const + operator VkDebugReportCallbackCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugReportCallbackCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugReportCallbackCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -25451,11 +26790,16 @@ public: return *this; } - operator const VkDebugMarkerObjectNameInfoEXT&() const + operator VkDebugMarkerObjectNameInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugMarkerObjectNameInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugMarkerObjectNameInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -25542,11 +26886,16 @@ public: return *this; } - operator const VkDebugMarkerObjectTagInfoEXT&() const + operator VkDebugMarkerObjectTagInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugMarkerObjectTagInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugMarkerObjectTagInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -25611,11 +26960,16 @@ public: return *this; } - operator const VkPipelineRasterizationStateRasterizationOrderAMD&() const + operator VkPipelineRasterizationStateRasterizationOrderAMD const&() const { return *reinterpret_cast(this); } + operator VkPipelineRasterizationStateRasterizationOrderAMD &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineRasterizationStateRasterizationOrderAMD const& rhs ) const { return ( sType == rhs.sType ) @@ -25694,11 +27048,16 @@ public: return *this; } - operator const VkExternalMemoryImageCreateInfoNV&() const + operator VkExternalMemoryImageCreateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkExternalMemoryImageCreateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalMemoryImageCreateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -25749,11 +27108,16 @@ public: return *this; } - operator const VkExportMemoryAllocateInfoNV&() const + operator VkExportMemoryAllocateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkExportMemoryAllocateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportMemoryAllocateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -25813,11 +27177,16 @@ public: return *this; } - operator const VkImportMemoryWin32HandleInfoNV&() const + operator VkImportMemoryWin32HandleInfoNV const&() const { return *reinterpret_cast(this); } + operator VkImportMemoryWin32HandleInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportMemoryWin32HandleInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -25871,11 +27240,16 @@ public: struct ExternalImageFormatPropertiesNV { - operator const VkExternalImageFormatPropertiesNV&() const + operator VkExternalImageFormatPropertiesNV const&() const { return *reinterpret_cast(this); } + operator VkExternalImageFormatPropertiesNV &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalImageFormatPropertiesNV const& rhs ) const { return ( imageFormatProperties == rhs.imageFormatProperties ) @@ -25939,11 +27313,16 @@ public: return *this; } - operator const VkValidationFlagsEXT&() const + operator VkValidationFlagsEXT const&() const { return *reinterpret_cast(this); } + operator VkValidationFlagsEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( ValidationFlagsEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -26002,11 +27381,16 @@ public: struct PhysicalDeviceSubgroupProperties { - operator const VkPhysicalDeviceSubgroupProperties&() const + operator VkPhysicalDeviceSubgroupProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceSubgroupProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceSubgroupProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -26139,11 +27523,16 @@ public: return *this; } - operator const VkIndirectCommandsTokenNVX&() const + operator VkIndirectCommandsTokenNVX const&() const { return *reinterpret_cast(this); } + operator VkIndirectCommandsTokenNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( IndirectCommandsTokenNVX const& rhs ) const { return ( tokenType == rhs.tokenType ) @@ -26209,11 +27598,16 @@ public: return *this; } - operator const VkIndirectCommandsLayoutTokenNVX&() const + operator VkIndirectCommandsLayoutTokenNVX const&() const { return *reinterpret_cast(this); } + operator VkIndirectCommandsLayoutTokenNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( IndirectCommandsLayoutTokenNVX const& rhs ) const { return ( tokenType == rhs.tokenType ) @@ -26287,11 +27681,16 @@ public: return *this; } - operator const VkIndirectCommandsLayoutCreateInfoNVX&() const + operator VkIndirectCommandsLayoutCreateInfoNVX const&() const { return *reinterpret_cast(this); } + operator VkIndirectCommandsLayoutCreateInfoNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( IndirectCommandsLayoutCreateInfoNVX const& rhs ) const { return ( sType == rhs.sType ) @@ -26421,11 +27820,16 @@ public: return *this; } - operator const VkObjectTableCreateInfoNVX&() const + operator VkObjectTableCreateInfoNVX const&() const { return *reinterpret_cast(this); } + operator VkObjectTableCreateInfoNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( ObjectTableCreateInfoNVX const& rhs ) const { return ( sType == rhs.sType ) @@ -26494,11 +27898,16 @@ public: return *this; } - operator const VkObjectTableEntryNVX&() const + operator VkObjectTableEntryNVX const&() const { return *reinterpret_cast(this); } + operator VkObjectTableEntryNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( ObjectTableEntryNVX const& rhs ) const { return ( type == rhs.type ) @@ -26561,11 +27970,16 @@ public: return *this; } - operator const VkObjectTablePipelineEntryNVX&() const + operator VkObjectTablePipelineEntryNVX const&() const { return *reinterpret_cast(this); } + operator VkObjectTablePipelineEntryNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( ObjectTablePipelineEntryNVX const& rhs ) const { return ( type == rhs.type ) @@ -26640,11 +28054,16 @@ public: return *this; } - operator const VkObjectTableDescriptorSetEntryNVX&() const + operator VkObjectTableDescriptorSetEntryNVX const&() const { return *reinterpret_cast(this); } + operator VkObjectTableDescriptorSetEntryNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( ObjectTableDescriptorSetEntryNVX const& rhs ) const { return ( type == rhs.type ) @@ -26711,11 +28130,16 @@ public: return *this; } - operator const VkObjectTableVertexBufferEntryNVX&() const + operator VkObjectTableVertexBufferEntryNVX const&() const { return *reinterpret_cast(this); } + operator VkObjectTableVertexBufferEntryNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( ObjectTableVertexBufferEntryNVX const& rhs ) const { return ( type == rhs.type ) @@ -26790,11 +28214,16 @@ public: return *this; } - operator const VkObjectTableIndexBufferEntryNVX&() const + operator VkObjectTableIndexBufferEntryNVX const&() const { return *reinterpret_cast(this); } + operator VkObjectTableIndexBufferEntryNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( ObjectTableIndexBufferEntryNVX const& rhs ) const { return ( type == rhs.type ) @@ -26871,11 +28300,16 @@ public: return *this; } - operator const VkObjectTablePushConstantEntryNVX&() const + operator VkObjectTablePushConstantEntryNVX const&() const { return *reinterpret_cast(this); } + operator VkObjectTablePushConstantEntryNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( ObjectTablePushConstantEntryNVX const& rhs ) const { return ( type == rhs.type ) @@ -26967,11 +28401,16 @@ public: return *this; } - operator const VkDescriptorSetLayoutCreateInfo&() const + operator VkDescriptorSetLayoutCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkDescriptorSetLayoutCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorSetLayoutCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27070,11 +28509,16 @@ public: return *this; } - operator const VkPhysicalDeviceExternalImageFormatInfo&() const + operator VkPhysicalDeviceExternalImageFormatInfo const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceExternalImageFormatInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceExternalImageFormatInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27143,11 +28587,16 @@ public: return *this; } - operator const VkPhysicalDeviceExternalBufferInfo&() const + operator VkPhysicalDeviceExternalBufferInfo const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceExternalBufferInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceExternalBufferInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27204,11 +28653,16 @@ public: return *this; } - operator const VkExternalMemoryImageCreateInfo&() const + operator VkExternalMemoryImageCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkExternalMemoryImageCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalMemoryImageCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27261,11 +28715,16 @@ public: return *this; } - operator const VkExternalMemoryBufferCreateInfo&() const + operator VkExternalMemoryBufferCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkExternalMemoryBufferCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalMemoryBufferCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27318,11 +28777,16 @@ public: return *this; } - operator const VkExportMemoryAllocateInfo&() const + operator VkExportMemoryAllocateInfo const&() const { return *reinterpret_cast(this); } + operator VkExportMemoryAllocateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportMemoryAllocateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27392,11 +28856,16 @@ public: return *this; } - operator const VkImportMemoryWin32HandleInfoKHR&() const + operator VkImportMemoryWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImportMemoryWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportMemoryWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -27461,11 +28930,16 @@ public: return *this; } - operator const VkMemoryGetWin32HandleInfoKHR&() const + operator VkMemoryGetWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkMemoryGetWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryGetWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -27527,11 +29001,16 @@ public: return *this; } - operator const VkImportMemoryFdInfoKHR&() const + operator VkImportMemoryFdInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImportMemoryFdInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportMemoryFdInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -27592,11 +29071,16 @@ public: return *this; } - operator const VkMemoryGetFdInfoKHR&() const + operator VkMemoryGetFdInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkMemoryGetFdInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryGetFdInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -27657,11 +29141,16 @@ public: return *this; } - operator const VkImportMemoryHostPointerInfoEXT&() const + operator VkImportMemoryHostPointerInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkImportMemoryHostPointerInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportMemoryHostPointerInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -27719,11 +29208,16 @@ public: struct ExternalMemoryProperties { - operator const VkExternalMemoryProperties&() const + operator VkExternalMemoryProperties const&() const { return *reinterpret_cast(this); } + operator VkExternalMemoryProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalMemoryProperties const& rhs ) const { return ( externalMemoryFeatures == rhs.externalMemoryFeatures ) @@ -27746,11 +29240,16 @@ public: struct ExternalImageFormatProperties { - operator const VkExternalImageFormatProperties&() const + operator VkExternalImageFormatProperties const&() const { return *reinterpret_cast(this); } + operator VkExternalImageFormatProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalImageFormatProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -27776,11 +29275,16 @@ public: struct ExternalBufferProperties { - operator const VkExternalBufferProperties&() const + operator VkExternalBufferProperties const&() const { return *reinterpret_cast(this); } + operator VkExternalBufferProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalBufferProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -27869,11 +29373,16 @@ public: return *this; } - operator const VkPhysicalDeviceExternalSemaphoreInfo&() const + operator VkPhysicalDeviceExternalSemaphoreInfo const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceExternalSemaphoreInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceExternalSemaphoreInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27926,11 +29435,16 @@ public: return *this; } - operator const VkExportSemaphoreCreateInfo&() const + operator VkExportSemaphoreCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkExportSemaphoreCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportSemaphoreCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -27992,11 +29506,16 @@ public: return *this; } - operator const VkSemaphoreGetWin32HandleInfoKHR&() const + operator VkSemaphoreGetWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkSemaphoreGetWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SemaphoreGetWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28058,11 +29577,16 @@ public: return *this; } - operator const VkSemaphoreGetFdInfoKHR&() const + operator VkSemaphoreGetFdInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkSemaphoreGetFdInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SemaphoreGetFdInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28118,11 +29642,16 @@ public: struct ExternalSemaphoreProperties { - operator const VkExternalSemaphoreProperties&() const + operator VkExternalSemaphoreProperties const&() const { return *reinterpret_cast(this); } + operator VkExternalSemaphoreProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalSemaphoreProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -28240,11 +29769,16 @@ public: return *this; } - operator const VkImportSemaphoreWin32HandleInfoKHR&() const + operator VkImportSemaphoreWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImportSemaphoreWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportSemaphoreWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28328,11 +29862,16 @@ public: return *this; } - operator const VkImportSemaphoreFdInfoKHR&() const + operator VkImportSemaphoreFdInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImportSemaphoreFdInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportSemaphoreFdInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28423,11 +29962,16 @@ public: return *this; } - operator const VkPhysicalDeviceExternalFenceInfo&() const + operator VkPhysicalDeviceExternalFenceInfo const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceExternalFenceInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceExternalFenceInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -28480,11 +30024,16 @@ public: return *this; } - operator const VkExportFenceCreateInfo&() const + operator VkExportFenceCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkExportFenceCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( ExportFenceCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -28546,11 +30095,16 @@ public: return *this; } - operator const VkFenceGetWin32HandleInfoKHR&() const + operator VkFenceGetWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkFenceGetWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( FenceGetWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28612,11 +30166,16 @@ public: return *this; } - operator const VkFenceGetFdInfoKHR&() const + operator VkFenceGetFdInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkFenceGetFdInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( FenceGetFdInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28672,11 +30231,16 @@ public: struct ExternalFenceProperties { - operator const VkExternalFenceProperties&() const + operator VkExternalFenceProperties const&() const { return *reinterpret_cast(this); } + operator VkExternalFenceProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( ExternalFenceProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -28794,11 +30358,16 @@ public: return *this; } - operator const VkImportFenceWin32HandleInfoKHR&() const + operator VkImportFenceWin32HandleInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImportFenceWin32HandleInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportFenceWin32HandleInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28882,11 +30451,16 @@ public: return *this; } - operator const VkImportFenceFdInfoKHR&() const + operator VkImportFenceFdInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkImportFenceFdInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( ImportFenceFdInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -28941,11 +30515,16 @@ public: struct SurfaceCapabilities2EXT { - operator const VkSurfaceCapabilities2EXT&() const + operator VkSurfaceCapabilities2EXT const&() const { return *reinterpret_cast(this); } + operator VkSurfaceCapabilities2EXT &() + { + return *reinterpret_cast(this); + } + bool operator==( SurfaceCapabilities2EXT const& rhs ) const { return ( sType == rhs.sType ) @@ -29016,11 +30595,16 @@ public: return *this; } - operator const VkSwapchainCounterCreateInfoEXT&() const + operator VkSwapchainCounterCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkSwapchainCounterCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( SwapchainCounterCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -29078,11 +30662,16 @@ public: return *this; } - operator const VkDisplayPowerInfoEXT&() const + operator VkDisplayPowerInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDisplayPowerInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayPowerInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -29138,11 +30727,16 @@ public: return *this; } - operator const VkDeviceEventInfoEXT&() const + operator VkDeviceEventInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDeviceEventInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceEventInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -29198,11 +30792,16 @@ public: return *this; } - operator const VkDisplayEventInfoEXT&() const + operator VkDisplayEventInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDisplayEventInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DisplayEventInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -29323,11 +30922,16 @@ public: return *this; } - operator const VkMemoryAllocateFlagsInfo&() const + operator VkMemoryAllocateFlagsInfo const&() const { return *reinterpret_cast(this); } + operator VkMemoryAllocateFlagsInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( MemoryAllocateFlagsInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -29383,11 +30987,16 @@ public: struct DeviceGroupPresentCapabilitiesKHR { - operator const VkDeviceGroupPresentCapabilitiesKHR&() const + operator VkDeviceGroupPresentCapabilitiesKHR const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupPresentCapabilitiesKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupPresentCapabilitiesKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -29456,11 +31065,16 @@ public: return *this; } - operator const VkDeviceGroupPresentInfoKHR&() const + operator VkDeviceGroupPresentInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupPresentInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupPresentInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -29515,11 +31129,16 @@ public: return *this; } - operator const VkDeviceGroupSwapchainCreateInfoKHR&() const + operator VkDeviceGroupSwapchainCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupSwapchainCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupSwapchainCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -29716,11 +31335,16 @@ public: return *this; } - operator const VkSwapchainCreateInfoKHR&() const + operator VkSwapchainCreateInfoKHR const&() const { return *reinterpret_cast(this); } + operator VkSwapchainCreateInfoKHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SwapchainCreateInfoKHR const& rhs ) const { return ( sType == rhs.sType ) @@ -29831,11 +31455,16 @@ public: return *this; } - operator const VkViewportSwizzleNV&() const + operator VkViewportSwizzleNV const&() const { return *reinterpret_cast(this); } + operator VkViewportSwizzleNV &() + { + return *reinterpret_cast(this); + } + bool operator==( ViewportSwizzleNV const& rhs ) const { return ( x == rhs.x ) @@ -29901,11 +31530,16 @@ public: return *this; } - operator const VkPipelineViewportSwizzleStateCreateInfoNV&() const + operator VkPipelineViewportSwizzleStateCreateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkPipelineViewportSwizzleStateCreateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineViewportSwizzleStateCreateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -29990,11 +31624,16 @@ public: return *this; } - operator const VkPipelineDiscardRectangleStateCreateInfoEXT&() const + operator VkPipelineDiscardRectangleStateCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkPipelineDiscardRectangleStateCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineDiscardRectangleStateCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -30143,11 +31782,16 @@ public: return *this; } - operator const VkSubpassDescription&() const + operator VkSubpassDescription const&() const { return *reinterpret_cast(this); } + operator VkSubpassDescription &() + { + return *reinterpret_cast(this); + } + bool operator==( SubpassDescription const& rhs ) const { return ( flags == rhs.flags ) @@ -30257,11 +31901,16 @@ public: return *this; } - operator const VkRenderPassCreateInfo&() const + operator VkRenderPassCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkRenderPassCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( RenderPassCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -30404,11 +32053,16 @@ public: return *this; } - operator const VkSubpassDescription2KHR&() const + operator VkSubpassDescription2KHR const&() const { return *reinterpret_cast(this); } + operator VkSubpassDescription2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( SubpassDescription2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -30543,11 +32197,16 @@ public: return *this; } - operator const VkRenderPassCreateInfo2KHR&() const + operator VkRenderPassCreateInfo2KHR const&() const { return *reinterpret_cast(this); } + operator VkRenderPassCreateInfo2KHR &() + { + return *reinterpret_cast(this); + } + bool operator==( RenderPassCreateInfo2KHR const& rhs ) const { return ( sType == rhs.sType ) @@ -30595,11 +32254,16 @@ public: struct PhysicalDevicePointClippingProperties { - operator const VkPhysicalDevicePointClippingProperties&() const + operator VkPhysicalDevicePointClippingProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDevicePointClippingProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDevicePointClippingProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -30659,11 +32323,16 @@ public: return *this; } - operator const VkSamplerReductionModeCreateInfoEXT&() const + operator VkSamplerReductionModeCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkSamplerReductionModeCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( SamplerReductionModeCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -30722,11 +32391,16 @@ public: return *this; } - operator const VkPipelineTessellationDomainOriginStateCreateInfo&() const + operator VkPipelineTessellationDomainOriginStateCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkPipelineTessellationDomainOriginStateCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineTessellationDomainOriginStateCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -30865,11 +32539,16 @@ public: return *this; } - operator const VkSamplerYcbcrConversionCreateInfo&() const + operator VkSamplerYcbcrConversionCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkSamplerYcbcrConversionCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SamplerYcbcrConversionCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -30910,11 +32589,16 @@ public: #ifdef VK_USE_PLATFORM_ANDROID_ANDROID struct AndroidHardwareBufferFormatPropertiesANDROID { - operator const VkAndroidHardwareBufferFormatPropertiesANDROID&() const + operator VkAndroidHardwareBufferFormatPropertiesANDROID const&() const { return *reinterpret_cast(this); } + operator VkAndroidHardwareBufferFormatPropertiesANDROID &() + { + return *reinterpret_cast(this); + } + bool operator==( AndroidHardwareBufferFormatPropertiesANDROID const& rhs ) const { return ( sType == rhs.sType ) @@ -31003,11 +32687,16 @@ public: return *this; } - operator const VkPipelineColorBlendAdvancedStateCreateInfoEXT&() const + operator VkPipelineColorBlendAdvancedStateCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkPipelineColorBlendAdvancedStateCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineColorBlendAdvancedStateCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -31102,11 +32791,16 @@ public: return *this; } - operator const VkPipelineCoverageModulationStateCreateInfoNV&() const + operator VkPipelineCoverageModulationStateCreateInfoNV const&() const { return *reinterpret_cast(this); } + operator VkPipelineCoverageModulationStateCreateInfoNV &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineCoverageModulationStateCreateInfoNV const& rhs ) const { return ( sType == rhs.sType ) @@ -31185,11 +32879,16 @@ public: return *this; } - operator const VkDeviceQueueGlobalPriorityCreateInfoEXT&() const + operator VkDeviceQueueGlobalPriorityCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDeviceQueueGlobalPriorityCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceQueueGlobalPriorityCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -31327,11 +33026,16 @@ public: return *this; } - operator const VkDebugUtilsMessengerCreateInfoEXT&() const + operator VkDebugUtilsMessengerCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDebugUtilsMessengerCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DebugUtilsMessengerCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -31413,11 +33117,16 @@ public: return *this; } - operator const VkPipelineRasterizationConservativeStateCreateInfoEXT&() const + operator VkPipelineRasterizationConservativeStateCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkPipelineRasterizationConservativeStateCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( PipelineRasterizationConservativeStateCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -31508,11 +33217,16 @@ public: return *this; } - operator const VkDescriptorSetLayoutBindingFlagsCreateInfoEXT&() const + operator VkDescriptorSetLayoutBindingFlagsCreateInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkDescriptorSetLayoutBindingFlagsCreateInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( DescriptorSetLayoutBindingFlagsCreateInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -31613,11 +33327,16 @@ public: return *this; } - operator const VkConditionalRenderingBeginInfoEXT&() const + operator VkConditionalRenderingBeginInfoEXT const&() const { return *reinterpret_cast(this); } + operator VkConditionalRenderingBeginInfoEXT &() + { + return *reinterpret_cast(this); + } + bool operator==( ConditionalRenderingBeginInfoEXT const& rhs ) const { return ( sType == rhs.sType ) @@ -33281,11 +35000,16 @@ public: return *this; } - operator const VkSubmitInfo&() const + operator VkSubmitInfo const&() const { return *reinterpret_cast(this); } + operator VkSubmitInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( SubmitInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -33557,59 +35281,59 @@ public: #ifndef VULKAN_HPP_NO_SMART_HANDLE class Device; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueBuffer = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueBufferView = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = PoolFree;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = PoolFree; }; using UniqueCommandBuffer = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueCommandPool = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueDescriptorPool = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = PoolFree;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = PoolFree; }; using UniqueDescriptorSet = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueDescriptorSetLayout = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueDescriptorUpdateTemplate = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectFree;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectFree; }; using UniqueDeviceMemory = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueEvent = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueFence = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueFramebuffer = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueImage = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueImageView = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueIndirectCommandsLayoutNVX = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueObjectTableNVX = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniquePipeline = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniquePipelineCache = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniquePipelineLayout = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueQueryPool = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueRenderPass = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueSampler = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueSamplerYcbcrConversion = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueSemaphore = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueShaderModule = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueSwapchainKHR = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Device; using deleter = ObjectDestroy; }; using UniqueValidationCacheEXT = UniqueHandle; #endif /*VULKAN_HPP_NO_SMART_HANDLE*/ @@ -34804,8 +36528,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template MemoryRequirements2 getBufferMemoryRequirements2( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; - template - StructureChain getBufferMemoryRequirements2( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; + template + StructureChain getBufferMemoryRequirements2( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -34813,8 +36537,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template MemoryRequirements2 getBufferMemoryRequirements2KHR( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; - template - StructureChain getBufferMemoryRequirements2KHR( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; + template + StructureChain getBufferMemoryRequirements2KHR( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -34822,8 +36546,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template MemoryRequirements2 getImageMemoryRequirements2( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; - template - StructureChain getImageMemoryRequirements2( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; + template + StructureChain getImageMemoryRequirements2( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -34831,8 +36555,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template MemoryRequirements2 getImageMemoryRequirements2KHR( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; - template - StructureChain getImageMemoryRequirements2KHR( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; + template + StructureChain getImageMemoryRequirements2KHR( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -34943,8 +36667,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template DescriptorSetLayoutSupport getDescriptorSetLayoutSupport( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d = Dispatch() ) const; - template - StructureChain getDescriptorSetLayoutSupport( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d = Dispatch() ) const; + template + StructureChain getDescriptorSetLayoutSupport( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -34952,8 +36676,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template DescriptorSetLayoutSupport getDescriptorSetLayoutSupportKHR( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d = Dispatch() ) const; - template - StructureChain getDescriptorSetLayoutSupportKHR( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d = Dispatch() ) const; + template + StructureChain getDescriptorSetLayoutSupportKHR( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -35001,8 +36725,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template ResultValueType::type getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const &d = Dispatch() ) const; - template - typename ResultValueType>::type getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const &d = Dispatch() ) const; + template + typename ResultValueType>::type getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VK_USE_PLATFORM_ANDROID_ANDROID*/ @@ -37597,10 +39321,10 @@ public: d.vkGetBufferMemoryRequirements2( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return memoryRequirements; } - template - VULKAN_HPP_INLINE StructureChain Device::getBufferMemoryRequirements2( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain Device::getBufferMemoryRequirements2( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; MemoryRequirements2& memoryRequirements = structureChain.template get(); d.vkGetBufferMemoryRequirements2( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return structureChain; @@ -37620,10 +39344,10 @@ public: d.vkGetBufferMemoryRequirements2KHR( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return memoryRequirements; } - template - VULKAN_HPP_INLINE StructureChain Device::getBufferMemoryRequirements2KHR( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain Device::getBufferMemoryRequirements2KHR( const BufferMemoryRequirementsInfo2 & info, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; MemoryRequirements2& memoryRequirements = structureChain.template get(); d.vkGetBufferMemoryRequirements2KHR( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return structureChain; @@ -37643,10 +39367,10 @@ public: d.vkGetImageMemoryRequirements2( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return memoryRequirements; } - template - VULKAN_HPP_INLINE StructureChain Device::getImageMemoryRequirements2( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain Device::getImageMemoryRequirements2( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; MemoryRequirements2& memoryRequirements = structureChain.template get(); d.vkGetImageMemoryRequirements2( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return structureChain; @@ -37666,10 +39390,10 @@ public: d.vkGetImageMemoryRequirements2KHR( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return memoryRequirements; } - template - VULKAN_HPP_INLINE StructureChain Device::getImageMemoryRequirements2KHR( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain Device::getImageMemoryRequirements2KHR( const ImageMemoryRequirementsInfo2 & info, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; MemoryRequirements2& memoryRequirements = structureChain.template get(); d.vkGetImageMemoryRequirements2KHR( m_device, reinterpret_cast( &info ), reinterpret_cast( &memoryRequirements ) ); return structureChain; @@ -37924,10 +39648,10 @@ public: d.vkGetDescriptorSetLayoutSupport( m_device, reinterpret_cast( &createInfo ), reinterpret_cast( &support ) ); return support; } - template - VULKAN_HPP_INLINE StructureChain Device::getDescriptorSetLayoutSupport( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain Device::getDescriptorSetLayoutSupport( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; DescriptorSetLayoutSupport& support = structureChain.template get(); d.vkGetDescriptorSetLayoutSupport( m_device, reinterpret_cast( &createInfo ), reinterpret_cast( &support ) ); return structureChain; @@ -37947,10 +39671,10 @@ public: d.vkGetDescriptorSetLayoutSupportKHR( m_device, reinterpret_cast( &createInfo ), reinterpret_cast( &support ) ); return support; } - template - VULKAN_HPP_INLINE StructureChain Device::getDescriptorSetLayoutSupportKHR( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain Device::getDescriptorSetLayoutSupportKHR( const DescriptorSetLayoutCreateInfo & createInfo, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; DescriptorSetLayoutSupport& support = structureChain.template get(); d.vkGetDescriptorSetLayoutSupportKHR( m_device, reinterpret_cast( &createInfo ), reinterpret_cast( &support ) ); return structureChain; @@ -38067,10 +39791,10 @@ public: Result result = static_cast( d.vkGetAndroidHardwareBufferPropertiesANDROID( m_device, buffer, reinterpret_cast( &properties ) ) ); return createResultValue( result, properties, VULKAN_HPP_NAMESPACE_STRING"::Device::getAndroidHardwareBufferPropertiesANDROID" ); } - template - VULKAN_HPP_INLINE typename ResultValueType>::type Device::getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const &d ) const + template + VULKAN_HPP_INLINE typename ResultValueType>::type Device::getAndroidHardwareBufferPropertiesANDROID( const struct AHardwareBuffer & buffer, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; AndroidHardwareBufferPropertiesANDROID& properties = structureChain.template get(); Result result = static_cast( d.vkGetAndroidHardwareBufferPropertiesANDROID( m_device, buffer, reinterpret_cast( &properties ) ) ); return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING"::Device::getAndroidHardwareBufferPropertiesANDROID" ); @@ -38097,7 +39821,7 @@ public: #ifndef VULKAN_HPP_NO_SMART_HANDLE - template class UniqueHandleTraits {public: using owner = NoParent; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = NoParent; using deleter = ObjectDestroy; }; using UniqueDevice = UniqueHandle; #endif /*VULKAN_HPP_NO_SMART_HANDLE*/ @@ -38349,8 +40073,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template PhysicalDeviceFeatures2 getFeatures2(Dispatch const &d = Dispatch() ) const; - template - StructureChain getFeatures2(Dispatch const &d = Dispatch() ) const; + template + StructureChain getFeatures2(Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -38358,8 +40082,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template PhysicalDeviceFeatures2 getFeatures2KHR(Dispatch const &d = Dispatch() ) const; - template - StructureChain getFeatures2KHR(Dispatch const &d = Dispatch() ) const; + template + StructureChain getFeatures2KHR(Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -38367,8 +40091,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template PhysicalDeviceProperties2 getProperties2(Dispatch const &d = Dispatch() ) const; - template - StructureChain getProperties2(Dispatch const &d = Dispatch() ) const; + template + StructureChain getProperties2(Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -38376,8 +40100,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template PhysicalDeviceProperties2 getProperties2KHR(Dispatch const &d = Dispatch() ) const; - template - StructureChain getProperties2KHR(Dispatch const &d = Dispatch() ) const; + template + StructureChain getProperties2KHR(Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -38399,8 +40123,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template ResultValueType::type getImageFormatProperties2( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d = Dispatch() ) const; - template - typename ResultValueType>::type getImageFormatProperties2( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d = Dispatch() ) const; + template + typename ResultValueType>::type getImageFormatProperties2( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -38408,8 +40132,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template ResultValueType::type getImageFormatProperties2KHR( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d = Dispatch() ) const; - template - typename ResultValueType>::type getImageFormatProperties2KHR( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d = Dispatch() ) const; + template + typename ResultValueType>::type getImageFormatProperties2KHR( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -38548,8 +40272,8 @@ public: #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template ResultValueType::type getSurfaceCapabilities2KHR( const PhysicalDeviceSurfaceInfo2KHR & surfaceInfo, Dispatch const &d = Dispatch() ) const; - template - typename ResultValueType>::type getSurfaceCapabilities2KHR( const PhysicalDeviceSurfaceInfo2KHR & surfaceInfo, Dispatch const &d = Dispatch() ) const; + template + typename ResultValueType>::type getSurfaceCapabilities2KHR( const PhysicalDeviceSurfaceInfo2KHR & surfaceInfo, Dispatch const &d = Dispatch() ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -39142,10 +40866,10 @@ public: d.vkGetPhysicalDeviceFeatures2( m_physicalDevice, reinterpret_cast( &features ) ); return features; } - template - VULKAN_HPP_INLINE StructureChain PhysicalDevice::getFeatures2(Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain PhysicalDevice::getFeatures2(Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; PhysicalDeviceFeatures2& features = structureChain.template get(); d.vkGetPhysicalDeviceFeatures2( m_physicalDevice, reinterpret_cast( &features ) ); return structureChain; @@ -39165,10 +40889,10 @@ public: d.vkGetPhysicalDeviceFeatures2KHR( m_physicalDevice, reinterpret_cast( &features ) ); return features; } - template - VULKAN_HPP_INLINE StructureChain PhysicalDevice::getFeatures2KHR(Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain PhysicalDevice::getFeatures2KHR(Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; PhysicalDeviceFeatures2& features = structureChain.template get(); d.vkGetPhysicalDeviceFeatures2KHR( m_physicalDevice, reinterpret_cast( &features ) ); return structureChain; @@ -39188,10 +40912,10 @@ public: d.vkGetPhysicalDeviceProperties2( m_physicalDevice, reinterpret_cast( &properties ) ); return properties; } - template - VULKAN_HPP_INLINE StructureChain PhysicalDevice::getProperties2(Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain PhysicalDevice::getProperties2(Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; PhysicalDeviceProperties2& properties = structureChain.template get(); d.vkGetPhysicalDeviceProperties2( m_physicalDevice, reinterpret_cast( &properties ) ); return structureChain; @@ -39211,10 +40935,10 @@ public: d.vkGetPhysicalDeviceProperties2KHR( m_physicalDevice, reinterpret_cast( &properties ) ); return properties; } - template - VULKAN_HPP_INLINE StructureChain PhysicalDevice::getProperties2KHR(Dispatch const &d ) const + template + VULKAN_HPP_INLINE StructureChain PhysicalDevice::getProperties2KHR(Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; PhysicalDeviceProperties2& properties = structureChain.template get(); d.vkGetPhysicalDeviceProperties2KHR( m_physicalDevice, reinterpret_cast( &properties ) ); return structureChain; @@ -39264,10 +40988,10 @@ public: Result result = static_cast( d.vkGetPhysicalDeviceImageFormatProperties2( m_physicalDevice, reinterpret_cast( &imageFormatInfo ), reinterpret_cast( &imageFormatProperties ) ) ); return createResultValue( result, imageFormatProperties, VULKAN_HPP_NAMESPACE_STRING"::PhysicalDevice::getImageFormatProperties2" ); } - template - VULKAN_HPP_INLINE typename ResultValueType>::type PhysicalDevice::getImageFormatProperties2( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d ) const + template + VULKAN_HPP_INLINE typename ResultValueType>::type PhysicalDevice::getImageFormatProperties2( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; ImageFormatProperties2& imageFormatProperties = structureChain.template get(); Result result = static_cast( d.vkGetPhysicalDeviceImageFormatProperties2( m_physicalDevice, reinterpret_cast( &imageFormatInfo ), reinterpret_cast( &imageFormatProperties ) ) ); return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING"::PhysicalDevice::getImageFormatProperties2" ); @@ -39287,10 +41011,10 @@ public: Result result = static_cast( d.vkGetPhysicalDeviceImageFormatProperties2KHR( m_physicalDevice, reinterpret_cast( &imageFormatInfo ), reinterpret_cast( &imageFormatProperties ) ) ); return createResultValue( result, imageFormatProperties, VULKAN_HPP_NAMESPACE_STRING"::PhysicalDevice::getImageFormatProperties2KHR" ); } - template - VULKAN_HPP_INLINE typename ResultValueType>::type PhysicalDevice::getImageFormatProperties2KHR( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d ) const + template + VULKAN_HPP_INLINE typename ResultValueType>::type PhysicalDevice::getImageFormatProperties2KHR( const PhysicalDeviceImageFormatInfo2 & imageFormatInfo, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; ImageFormatProperties2& imageFormatProperties = structureChain.template get(); Result result = static_cast( d.vkGetPhysicalDeviceImageFormatProperties2KHR( m_physicalDevice, reinterpret_cast( &imageFormatInfo ), reinterpret_cast( &imageFormatProperties ) ) ); return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING"::PhysicalDevice::getImageFormatProperties2KHR" ); @@ -39608,10 +41332,10 @@ public: Result result = static_cast( d.vkGetPhysicalDeviceSurfaceCapabilities2KHR( m_physicalDevice, reinterpret_cast( &surfaceInfo ), reinterpret_cast( &surfaceCapabilities ) ) ); return createResultValue( result, surfaceCapabilities, VULKAN_HPP_NAMESPACE_STRING"::PhysicalDevice::getSurfaceCapabilities2KHR" ); } - template - VULKAN_HPP_INLINE typename ResultValueType>::type PhysicalDevice::getSurfaceCapabilities2KHR( const PhysicalDeviceSurfaceInfo2KHR & surfaceInfo, Dispatch const &d ) const + template + VULKAN_HPP_INLINE typename ResultValueType>::type PhysicalDevice::getSurfaceCapabilities2KHR( const PhysicalDeviceSurfaceInfo2KHR & surfaceInfo, Dispatch const &d ) const { - StructureChain structureChain; + StructureChain structureChain; SurfaceCapabilities2KHR& surfaceCapabilities = structureChain.template get(); Result result = static_cast( d.vkGetPhysicalDeviceSurfaceCapabilities2KHR( m_physicalDevice, reinterpret_cast( &surfaceInfo ), reinterpret_cast( &surfaceCapabilities ) ) ); return createResultValue( result, structureChain, VULKAN_HPP_NAMESPACE_STRING"::PhysicalDevice::getSurfaceCapabilities2KHR" ); @@ -39842,11 +41566,16 @@ public: return *this; } - operator const VkCmdProcessCommandsInfoNVX&() const + operator VkCmdProcessCommandsInfoNVX const&() const { return *reinterpret_cast(this); } + operator VkCmdProcessCommandsInfoNVX &() + { + return *reinterpret_cast(this); + } + bool operator==( CmdProcessCommandsInfoNVX const& rhs ) const { return ( sType == rhs.sType ) @@ -39888,11 +41617,16 @@ public: struct PhysicalDeviceGroupProperties { - operator const VkPhysicalDeviceGroupProperties&() const + operator VkPhysicalDeviceGroupProperties const&() const { return *reinterpret_cast(this); } + operator VkPhysicalDeviceGroupProperties &() + { + return *reinterpret_cast(this); + } + bool operator==( PhysicalDeviceGroupProperties const& rhs ) const { return ( sType == rhs.sType ) @@ -39923,11 +41657,11 @@ public: #ifndef VULKAN_HPP_NO_SMART_HANDLE class Instance; - template class UniqueHandleTraits {public: using owner = Instance; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Instance; using deleter = ObjectDestroy; }; using UniqueDebugReportCallbackEXT = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Instance; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Instance; using deleter = ObjectDestroy; }; using UniqueDebugUtilsMessengerEXT = UniqueHandle; - template class UniqueHandleTraits {public: using owner = Instance; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = Instance; using deleter = ObjectDestroy; }; using UniqueSurfaceKHR = UniqueHandle; #endif /*VULKAN_HPP_NO_SMART_HANDLE*/ @@ -40825,11 +42559,16 @@ public: return *this; } - operator const VkDeviceGroupDeviceCreateInfo&() const + operator VkDeviceGroupDeviceCreateInfo const&() const { return *reinterpret_cast(this); } + operator VkDeviceGroupDeviceCreateInfo &() + { + return *reinterpret_cast(this); + } + bool operator==( DeviceGroupDeviceCreateInfo const& rhs ) const { return ( sType == rhs.sType ) @@ -40857,7 +42596,7 @@ public: #ifndef VULKAN_HPP_NO_SMART_HANDLE - template class UniqueHandleTraits {public: using owner = NoParent; using deleter = ObjectDestroy;}; + template class UniqueHandleTraits {public: using owner = NoParent; using deleter = ObjectDestroy; }; using UniqueInstance = UniqueHandle; #endif /*VULKAN_HPP_NO_SMART_HANDLE*/ @@ -40921,11 +42660,16 @@ public: return *this; } - operator const VkBaseOutStructure&() const + operator VkBaseOutStructure const&() const { return *reinterpret_cast(this); } + operator VkBaseOutStructure &() + { + return *reinterpret_cast(this); + } + bool operator==( BaseOutStructure const& rhs ) const { return ( sType == rhs.sType ) @@ -40964,11 +42708,16 @@ public: return *this; } - operator const VkBaseInStructure&() const + operator VkBaseInStructure const&() const { return *reinterpret_cast(this); } + operator VkBaseInStructure &() + { + return *reinterpret_cast(this); + } + bool operator==( BaseInStructure const& rhs ) const { return ( sType == rhs.sType ) @@ -44819,7 +46568,7 @@ public: vkAcquireNextImage2KHR = PFN_vkAcquireNextImage2KHR(device ? device.getProcAddr( "vkAcquireNextImage2KHR") : instance.getProcAddr( "vkAcquireNextImage2KHR")); vkAcquireNextImageKHR = PFN_vkAcquireNextImageKHR(device ? device.getProcAddr( "vkAcquireNextImageKHR") : instance.getProcAddr( "vkAcquireNextImageKHR")); #ifdef VK_USE_PLATFORM_XLIB_XRANDR_NV - vkAcquireXlibDisplayEXT = PFN_vkAcquireXlibDisplayEXT(device ? device.getProcAddr( "vkAcquireXlibDisplayEXT") : instance.getProcAddr( "vkAcquireXlibDisplayEXT")); + vkAcquireXlibDisplayEXT = PFN_vkAcquireXlibDisplayEXT(instance.getProcAddr( "vkAcquireXlibDisplayEXT")); #endif /*VK_USE_PLATFORM_XLIB_XRANDR_NV*/ vkAllocateCommandBuffers = PFN_vkAllocateCommandBuffers(device ? device.getProcAddr( "vkAllocateCommandBuffers") : instance.getProcAddr( "vkAllocateCommandBuffers")); vkAllocateDescriptorSets = PFN_vkAllocateDescriptorSets(device ? device.getProcAddr( "vkAllocateDescriptorSets") : instance.getProcAddr( "vkAllocateDescriptorSets")); @@ -44916,8 +46665,8 @@ public: vkCreateDescriptorSetLayout = PFN_vkCreateDescriptorSetLayout(device ? device.getProcAddr( "vkCreateDescriptorSetLayout") : instance.getProcAddr( "vkCreateDescriptorSetLayout")); vkCreateDescriptorUpdateTemplate = PFN_vkCreateDescriptorUpdateTemplate(device ? device.getProcAddr( "vkCreateDescriptorUpdateTemplate") : instance.getProcAddr( "vkCreateDescriptorUpdateTemplate")); vkCreateDescriptorUpdateTemplateKHR = PFN_vkCreateDescriptorUpdateTemplateKHR(device ? device.getProcAddr( "vkCreateDescriptorUpdateTemplateKHR") : instance.getProcAddr( "vkCreateDescriptorUpdateTemplateKHR")); - vkCreateDevice = PFN_vkCreateDevice(device ? device.getProcAddr( "vkCreateDevice") : instance.getProcAddr( "vkCreateDevice")); - vkCreateDisplayModeKHR = PFN_vkCreateDisplayModeKHR(device ? device.getProcAddr( "vkCreateDisplayModeKHR") : instance.getProcAddr( "vkCreateDisplayModeKHR")); + vkCreateDevice = PFN_vkCreateDevice(instance.getProcAddr( "vkCreateDevice")); + vkCreateDisplayModeKHR = PFN_vkCreateDisplayModeKHR(instance.getProcAddr( "vkCreateDisplayModeKHR")); vkCreateDisplayPlaneSurfaceKHR = PFN_vkCreateDisplayPlaneSurfaceKHR(instance.getProcAddr( "vkCreateDisplayPlaneSurfaceKHR")); vkCreateEvent = PFN_vkCreateEvent(device ? device.getProcAddr( "vkCreateEvent") : instance.getProcAddr( "vkCreateEvent")); vkCreateFence = PFN_vkCreateFence(device ? device.getProcAddr( "vkCreateFence") : instance.getProcAddr( "vkCreateFence")); @@ -45002,8 +46751,8 @@ public: vkDeviceWaitIdle = PFN_vkDeviceWaitIdle(device ? device.getProcAddr( "vkDeviceWaitIdle") : instance.getProcAddr( "vkDeviceWaitIdle")); vkDisplayPowerControlEXT = PFN_vkDisplayPowerControlEXT(device ? device.getProcAddr( "vkDisplayPowerControlEXT") : instance.getProcAddr( "vkDisplayPowerControlEXT")); vkEndCommandBuffer = PFN_vkEndCommandBuffer(device ? device.getProcAddr( "vkEndCommandBuffer") : instance.getProcAddr( "vkEndCommandBuffer")); - vkEnumerateDeviceExtensionProperties = PFN_vkEnumerateDeviceExtensionProperties(device ? device.getProcAddr( "vkEnumerateDeviceExtensionProperties") : instance.getProcAddr( "vkEnumerateDeviceExtensionProperties")); - vkEnumerateDeviceLayerProperties = PFN_vkEnumerateDeviceLayerProperties(device ? device.getProcAddr( "vkEnumerateDeviceLayerProperties") : instance.getProcAddr( "vkEnumerateDeviceLayerProperties")); + vkEnumerateDeviceExtensionProperties = PFN_vkEnumerateDeviceExtensionProperties(instance.getProcAddr( "vkEnumerateDeviceExtensionProperties")); + vkEnumerateDeviceLayerProperties = PFN_vkEnumerateDeviceLayerProperties(instance.getProcAddr( "vkEnumerateDeviceLayerProperties")); vkEnumerateInstanceExtensionProperties = PFN_vkEnumerateInstanceExtensionProperties(instance.getProcAddr( "vkEnumerateInstanceExtensionProperties")); vkEnumerateInstanceLayerProperties = PFN_vkEnumerateInstanceLayerProperties(instance.getProcAddr( "vkEnumerateInstanceLayerProperties")); vkEnumerateInstanceVersion = PFN_vkEnumerateInstanceVersion(instance.getProcAddr( "vkEnumerateInstanceVersion")); @@ -45030,11 +46779,11 @@ public: vkGetDeviceProcAddr = PFN_vkGetDeviceProcAddr(device ? device.getProcAddr( "vkGetDeviceProcAddr") : instance.getProcAddr( "vkGetDeviceProcAddr")); vkGetDeviceQueue = PFN_vkGetDeviceQueue(device ? device.getProcAddr( "vkGetDeviceQueue") : instance.getProcAddr( "vkGetDeviceQueue")); vkGetDeviceQueue2 = PFN_vkGetDeviceQueue2(device ? device.getProcAddr( "vkGetDeviceQueue2") : instance.getProcAddr( "vkGetDeviceQueue2")); - vkGetDisplayModeProperties2KHR = PFN_vkGetDisplayModeProperties2KHR(device ? device.getProcAddr( "vkGetDisplayModeProperties2KHR") : instance.getProcAddr( "vkGetDisplayModeProperties2KHR")); - vkGetDisplayModePropertiesKHR = PFN_vkGetDisplayModePropertiesKHR(device ? device.getProcAddr( "vkGetDisplayModePropertiesKHR") : instance.getProcAddr( "vkGetDisplayModePropertiesKHR")); - vkGetDisplayPlaneCapabilities2KHR = PFN_vkGetDisplayPlaneCapabilities2KHR(device ? device.getProcAddr( "vkGetDisplayPlaneCapabilities2KHR") : instance.getProcAddr( "vkGetDisplayPlaneCapabilities2KHR")); - vkGetDisplayPlaneCapabilitiesKHR = PFN_vkGetDisplayPlaneCapabilitiesKHR(device ? device.getProcAddr( "vkGetDisplayPlaneCapabilitiesKHR") : instance.getProcAddr( "vkGetDisplayPlaneCapabilitiesKHR")); - vkGetDisplayPlaneSupportedDisplaysKHR = PFN_vkGetDisplayPlaneSupportedDisplaysKHR(device ? device.getProcAddr( "vkGetDisplayPlaneSupportedDisplaysKHR") : instance.getProcAddr( "vkGetDisplayPlaneSupportedDisplaysKHR")); + vkGetDisplayModeProperties2KHR = PFN_vkGetDisplayModeProperties2KHR(instance.getProcAddr( "vkGetDisplayModeProperties2KHR")); + vkGetDisplayModePropertiesKHR = PFN_vkGetDisplayModePropertiesKHR(instance.getProcAddr( "vkGetDisplayModePropertiesKHR")); + vkGetDisplayPlaneCapabilities2KHR = PFN_vkGetDisplayPlaneCapabilities2KHR(instance.getProcAddr( "vkGetDisplayPlaneCapabilities2KHR")); + vkGetDisplayPlaneCapabilitiesKHR = PFN_vkGetDisplayPlaneCapabilitiesKHR(instance.getProcAddr( "vkGetDisplayPlaneCapabilitiesKHR")); + vkGetDisplayPlaneSupportedDisplaysKHR = PFN_vkGetDisplayPlaneSupportedDisplaysKHR(instance.getProcAddr( "vkGetDisplayPlaneSupportedDisplaysKHR")); vkGetEventStatus = PFN_vkGetEventStatus(device ? device.getProcAddr( "vkGetEventStatus") : instance.getProcAddr( "vkGetEventStatus")); vkGetFenceFdKHR = PFN_vkGetFenceFdKHR(device ? device.getProcAddr( "vkGetFenceFdKHR") : instance.getProcAddr( "vkGetFenceFdKHR")); vkGetFenceStatus = PFN_vkGetFenceStatus(device ? device.getProcAddr( "vkGetFenceStatus") : instance.getProcAddr( "vkGetFenceStatus")); @@ -45065,68 +46814,68 @@ public: vkGetMemoryWin32HandlePropertiesKHR = PFN_vkGetMemoryWin32HandlePropertiesKHR(device ? device.getProcAddr( "vkGetMemoryWin32HandlePropertiesKHR") : instance.getProcAddr( "vkGetMemoryWin32HandlePropertiesKHR")); #endif /*VK_USE_PLATFORM_WIN32_KHR*/ vkGetPastPresentationTimingGOOGLE = PFN_vkGetPastPresentationTimingGOOGLE(device ? device.getProcAddr( "vkGetPastPresentationTimingGOOGLE") : instance.getProcAddr( "vkGetPastPresentationTimingGOOGLE")); - vkGetPhysicalDeviceDisplayPlaneProperties2KHR = PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceDisplayPlaneProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceDisplayPlaneProperties2KHR")); - vkGetPhysicalDeviceDisplayPlanePropertiesKHR = PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceDisplayPlanePropertiesKHR") : instance.getProcAddr( "vkGetPhysicalDeviceDisplayPlanePropertiesKHR")); - vkGetPhysicalDeviceDisplayProperties2KHR = PFN_vkGetPhysicalDeviceDisplayProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceDisplayProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceDisplayProperties2KHR")); - vkGetPhysicalDeviceDisplayPropertiesKHR = PFN_vkGetPhysicalDeviceDisplayPropertiesKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceDisplayPropertiesKHR") : instance.getProcAddr( "vkGetPhysicalDeviceDisplayPropertiesKHR")); - vkGetPhysicalDeviceExternalBufferProperties = PFN_vkGetPhysicalDeviceExternalBufferProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceExternalBufferProperties") : instance.getProcAddr( "vkGetPhysicalDeviceExternalBufferProperties")); - vkGetPhysicalDeviceExternalBufferPropertiesKHR = PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceExternalBufferPropertiesKHR") : instance.getProcAddr( "vkGetPhysicalDeviceExternalBufferPropertiesKHR")); - vkGetPhysicalDeviceExternalFenceProperties = PFN_vkGetPhysicalDeviceExternalFenceProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceExternalFenceProperties") : instance.getProcAddr( "vkGetPhysicalDeviceExternalFenceProperties")); - vkGetPhysicalDeviceExternalFencePropertiesKHR = PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceExternalFencePropertiesKHR") : instance.getProcAddr( "vkGetPhysicalDeviceExternalFencePropertiesKHR")); - vkGetPhysicalDeviceExternalImageFormatPropertiesNV = PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV(device ? device.getProcAddr( "vkGetPhysicalDeviceExternalImageFormatPropertiesNV") : instance.getProcAddr( "vkGetPhysicalDeviceExternalImageFormatPropertiesNV")); - vkGetPhysicalDeviceExternalSemaphoreProperties = PFN_vkGetPhysicalDeviceExternalSemaphoreProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceExternalSemaphoreProperties") : instance.getProcAddr( "vkGetPhysicalDeviceExternalSemaphoreProperties")); - vkGetPhysicalDeviceExternalSemaphorePropertiesKHR = PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR") : instance.getProcAddr( "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR")); - vkGetPhysicalDeviceFeatures = PFN_vkGetPhysicalDeviceFeatures(device ? device.getProcAddr( "vkGetPhysicalDeviceFeatures") : instance.getProcAddr( "vkGetPhysicalDeviceFeatures")); - vkGetPhysicalDeviceFeatures2 = PFN_vkGetPhysicalDeviceFeatures2(device ? device.getProcAddr( "vkGetPhysicalDeviceFeatures2") : instance.getProcAddr( "vkGetPhysicalDeviceFeatures2")); - vkGetPhysicalDeviceFeatures2KHR = PFN_vkGetPhysicalDeviceFeatures2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceFeatures2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceFeatures2KHR")); - vkGetPhysicalDeviceFormatProperties = PFN_vkGetPhysicalDeviceFormatProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceFormatProperties") : instance.getProcAddr( "vkGetPhysicalDeviceFormatProperties")); - vkGetPhysicalDeviceFormatProperties2 = PFN_vkGetPhysicalDeviceFormatProperties2(device ? device.getProcAddr( "vkGetPhysicalDeviceFormatProperties2") : instance.getProcAddr( "vkGetPhysicalDeviceFormatProperties2")); - vkGetPhysicalDeviceFormatProperties2KHR = PFN_vkGetPhysicalDeviceFormatProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceFormatProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceFormatProperties2KHR")); - vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX = PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX(device ? device.getProcAddr( "vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX") : instance.getProcAddr( "vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX")); - vkGetPhysicalDeviceImageFormatProperties = PFN_vkGetPhysicalDeviceImageFormatProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties") : instance.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties")); - vkGetPhysicalDeviceImageFormatProperties2 = PFN_vkGetPhysicalDeviceImageFormatProperties2(device ? device.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties2") : instance.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties2")); - vkGetPhysicalDeviceImageFormatProperties2KHR = PFN_vkGetPhysicalDeviceImageFormatProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties2KHR")); - vkGetPhysicalDeviceMemoryProperties = PFN_vkGetPhysicalDeviceMemoryProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceMemoryProperties") : instance.getProcAddr( "vkGetPhysicalDeviceMemoryProperties")); - vkGetPhysicalDeviceMemoryProperties2 = PFN_vkGetPhysicalDeviceMemoryProperties2(device ? device.getProcAddr( "vkGetPhysicalDeviceMemoryProperties2") : instance.getProcAddr( "vkGetPhysicalDeviceMemoryProperties2")); - vkGetPhysicalDeviceMemoryProperties2KHR = PFN_vkGetPhysicalDeviceMemoryProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceMemoryProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceMemoryProperties2KHR")); + vkGetPhysicalDeviceDisplayPlaneProperties2KHR = PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceDisplayPlaneProperties2KHR")); + vkGetPhysicalDeviceDisplayPlanePropertiesKHR = PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR(instance.getProcAddr( "vkGetPhysicalDeviceDisplayPlanePropertiesKHR")); + vkGetPhysicalDeviceDisplayProperties2KHR = PFN_vkGetPhysicalDeviceDisplayProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceDisplayProperties2KHR")); + vkGetPhysicalDeviceDisplayPropertiesKHR = PFN_vkGetPhysicalDeviceDisplayPropertiesKHR(instance.getProcAddr( "vkGetPhysicalDeviceDisplayPropertiesKHR")); + vkGetPhysicalDeviceExternalBufferProperties = PFN_vkGetPhysicalDeviceExternalBufferProperties(instance.getProcAddr( "vkGetPhysicalDeviceExternalBufferProperties")); + vkGetPhysicalDeviceExternalBufferPropertiesKHR = PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR(instance.getProcAddr( "vkGetPhysicalDeviceExternalBufferPropertiesKHR")); + vkGetPhysicalDeviceExternalFenceProperties = PFN_vkGetPhysicalDeviceExternalFenceProperties(instance.getProcAddr( "vkGetPhysicalDeviceExternalFenceProperties")); + vkGetPhysicalDeviceExternalFencePropertiesKHR = PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR(instance.getProcAddr( "vkGetPhysicalDeviceExternalFencePropertiesKHR")); + vkGetPhysicalDeviceExternalImageFormatPropertiesNV = PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV(instance.getProcAddr( "vkGetPhysicalDeviceExternalImageFormatPropertiesNV")); + vkGetPhysicalDeviceExternalSemaphoreProperties = PFN_vkGetPhysicalDeviceExternalSemaphoreProperties(instance.getProcAddr( "vkGetPhysicalDeviceExternalSemaphoreProperties")); + vkGetPhysicalDeviceExternalSemaphorePropertiesKHR = PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(instance.getProcAddr( "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR")); + vkGetPhysicalDeviceFeatures = PFN_vkGetPhysicalDeviceFeatures(instance.getProcAddr( "vkGetPhysicalDeviceFeatures")); + vkGetPhysicalDeviceFeatures2 = PFN_vkGetPhysicalDeviceFeatures2(instance.getProcAddr( "vkGetPhysicalDeviceFeatures2")); + vkGetPhysicalDeviceFeatures2KHR = PFN_vkGetPhysicalDeviceFeatures2KHR(instance.getProcAddr( "vkGetPhysicalDeviceFeatures2KHR")); + vkGetPhysicalDeviceFormatProperties = PFN_vkGetPhysicalDeviceFormatProperties(instance.getProcAddr( "vkGetPhysicalDeviceFormatProperties")); + vkGetPhysicalDeviceFormatProperties2 = PFN_vkGetPhysicalDeviceFormatProperties2(instance.getProcAddr( "vkGetPhysicalDeviceFormatProperties2")); + vkGetPhysicalDeviceFormatProperties2KHR = PFN_vkGetPhysicalDeviceFormatProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceFormatProperties2KHR")); + vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX = PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX(instance.getProcAddr( "vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX")); + vkGetPhysicalDeviceImageFormatProperties = PFN_vkGetPhysicalDeviceImageFormatProperties(instance.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties")); + vkGetPhysicalDeviceImageFormatProperties2 = PFN_vkGetPhysicalDeviceImageFormatProperties2(instance.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties2")); + vkGetPhysicalDeviceImageFormatProperties2KHR = PFN_vkGetPhysicalDeviceImageFormatProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceImageFormatProperties2KHR")); + vkGetPhysicalDeviceMemoryProperties = PFN_vkGetPhysicalDeviceMemoryProperties(instance.getProcAddr( "vkGetPhysicalDeviceMemoryProperties")); + vkGetPhysicalDeviceMemoryProperties2 = PFN_vkGetPhysicalDeviceMemoryProperties2(instance.getProcAddr( "vkGetPhysicalDeviceMemoryProperties2")); + vkGetPhysicalDeviceMemoryProperties2KHR = PFN_vkGetPhysicalDeviceMemoryProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceMemoryProperties2KHR")); #ifdef VK_USE_PLATFORM_MIR_KHR - vkGetPhysicalDeviceMirPresentationSupportKHR = PFN_vkGetPhysicalDeviceMirPresentationSupportKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceMirPresentationSupportKHR") : instance.getProcAddr( "vkGetPhysicalDeviceMirPresentationSupportKHR")); + vkGetPhysicalDeviceMirPresentationSupportKHR = PFN_vkGetPhysicalDeviceMirPresentationSupportKHR(instance.getProcAddr( "vkGetPhysicalDeviceMirPresentationSupportKHR")); #endif /*VK_USE_PLATFORM_MIR_KHR*/ - vkGetPhysicalDeviceMultisamplePropertiesEXT = PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT(device ? device.getProcAddr( "vkGetPhysicalDeviceMultisamplePropertiesEXT") : instance.getProcAddr( "vkGetPhysicalDeviceMultisamplePropertiesEXT")); - vkGetPhysicalDevicePresentRectanglesKHR = PFN_vkGetPhysicalDevicePresentRectanglesKHR(device ? device.getProcAddr( "vkGetPhysicalDevicePresentRectanglesKHR") : instance.getProcAddr( "vkGetPhysicalDevicePresentRectanglesKHR")); - vkGetPhysicalDeviceProperties = PFN_vkGetPhysicalDeviceProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceProperties") : instance.getProcAddr( "vkGetPhysicalDeviceProperties")); - vkGetPhysicalDeviceProperties2 = PFN_vkGetPhysicalDeviceProperties2(device ? device.getProcAddr( "vkGetPhysicalDeviceProperties2") : instance.getProcAddr( "vkGetPhysicalDeviceProperties2")); - vkGetPhysicalDeviceProperties2KHR = PFN_vkGetPhysicalDeviceProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceProperties2KHR")); - vkGetPhysicalDeviceQueueFamilyProperties = PFN_vkGetPhysicalDeviceQueueFamilyProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties") : instance.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties")); - vkGetPhysicalDeviceQueueFamilyProperties2 = PFN_vkGetPhysicalDeviceQueueFamilyProperties2(device ? device.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties2") : instance.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties2")); - vkGetPhysicalDeviceQueueFamilyProperties2KHR = PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties2KHR")); - vkGetPhysicalDeviceSparseImageFormatProperties = PFN_vkGetPhysicalDeviceSparseImageFormatProperties(device ? device.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties") : instance.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties")); - vkGetPhysicalDeviceSparseImageFormatProperties2 = PFN_vkGetPhysicalDeviceSparseImageFormatProperties2(device ? device.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties2") : instance.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties2")); - vkGetPhysicalDeviceSparseImageFormatProperties2KHR = PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties2KHR")); - vkGetPhysicalDeviceSurfaceCapabilities2EXT = PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT(device ? device.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilities2EXT") : instance.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilities2EXT")); - vkGetPhysicalDeviceSurfaceCapabilities2KHR = PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilities2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilities2KHR")); - vkGetPhysicalDeviceSurfaceCapabilitiesKHR = PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilitiesKHR") : instance.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilitiesKHR")); - vkGetPhysicalDeviceSurfaceFormats2KHR = PFN_vkGetPhysicalDeviceSurfaceFormats2KHR(device ? device.getProcAddr( "vkGetPhysicalDeviceSurfaceFormats2KHR") : instance.getProcAddr( "vkGetPhysicalDeviceSurfaceFormats2KHR")); - vkGetPhysicalDeviceSurfaceFormatsKHR = PFN_vkGetPhysicalDeviceSurfaceFormatsKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceSurfaceFormatsKHR") : instance.getProcAddr( "vkGetPhysicalDeviceSurfaceFormatsKHR")); - vkGetPhysicalDeviceSurfacePresentModesKHR = PFN_vkGetPhysicalDeviceSurfacePresentModesKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceSurfacePresentModesKHR") : instance.getProcAddr( "vkGetPhysicalDeviceSurfacePresentModesKHR")); - vkGetPhysicalDeviceSurfaceSupportKHR = PFN_vkGetPhysicalDeviceSurfaceSupportKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceSurfaceSupportKHR") : instance.getProcAddr( "vkGetPhysicalDeviceSurfaceSupportKHR")); + vkGetPhysicalDeviceMultisamplePropertiesEXT = PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT(instance.getProcAddr( "vkGetPhysicalDeviceMultisamplePropertiesEXT")); + vkGetPhysicalDevicePresentRectanglesKHR = PFN_vkGetPhysicalDevicePresentRectanglesKHR(instance.getProcAddr( "vkGetPhysicalDevicePresentRectanglesKHR")); + vkGetPhysicalDeviceProperties = PFN_vkGetPhysicalDeviceProperties(instance.getProcAddr( "vkGetPhysicalDeviceProperties")); + vkGetPhysicalDeviceProperties2 = PFN_vkGetPhysicalDeviceProperties2(instance.getProcAddr( "vkGetPhysicalDeviceProperties2")); + vkGetPhysicalDeviceProperties2KHR = PFN_vkGetPhysicalDeviceProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceProperties2KHR")); + vkGetPhysicalDeviceQueueFamilyProperties = PFN_vkGetPhysicalDeviceQueueFamilyProperties(instance.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties")); + vkGetPhysicalDeviceQueueFamilyProperties2 = PFN_vkGetPhysicalDeviceQueueFamilyProperties2(instance.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties2")); + vkGetPhysicalDeviceQueueFamilyProperties2KHR = PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceQueueFamilyProperties2KHR")); + vkGetPhysicalDeviceSparseImageFormatProperties = PFN_vkGetPhysicalDeviceSparseImageFormatProperties(instance.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties")); + vkGetPhysicalDeviceSparseImageFormatProperties2 = PFN_vkGetPhysicalDeviceSparseImageFormatProperties2(instance.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties2")); + vkGetPhysicalDeviceSparseImageFormatProperties2KHR = PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR(instance.getProcAddr( "vkGetPhysicalDeviceSparseImageFormatProperties2KHR")); + vkGetPhysicalDeviceSurfaceCapabilities2EXT = PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT(instance.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilities2EXT")); + vkGetPhysicalDeviceSurfaceCapabilities2KHR = PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR(instance.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilities2KHR")); + vkGetPhysicalDeviceSurfaceCapabilitiesKHR = PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(instance.getProcAddr( "vkGetPhysicalDeviceSurfaceCapabilitiesKHR")); + vkGetPhysicalDeviceSurfaceFormats2KHR = PFN_vkGetPhysicalDeviceSurfaceFormats2KHR(instance.getProcAddr( "vkGetPhysicalDeviceSurfaceFormats2KHR")); + vkGetPhysicalDeviceSurfaceFormatsKHR = PFN_vkGetPhysicalDeviceSurfaceFormatsKHR(instance.getProcAddr( "vkGetPhysicalDeviceSurfaceFormatsKHR")); + vkGetPhysicalDeviceSurfacePresentModesKHR = PFN_vkGetPhysicalDeviceSurfacePresentModesKHR(instance.getProcAddr( "vkGetPhysicalDeviceSurfacePresentModesKHR")); + vkGetPhysicalDeviceSurfaceSupportKHR = PFN_vkGetPhysicalDeviceSurfaceSupportKHR(instance.getProcAddr( "vkGetPhysicalDeviceSurfaceSupportKHR")); #ifdef VK_USE_PLATFORM_WAYLAND_KHR - vkGetPhysicalDeviceWaylandPresentationSupportKHR = PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceWaylandPresentationSupportKHR") : instance.getProcAddr( "vkGetPhysicalDeviceWaylandPresentationSupportKHR")); + vkGetPhysicalDeviceWaylandPresentationSupportKHR = PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR(instance.getProcAddr( "vkGetPhysicalDeviceWaylandPresentationSupportKHR")); #endif /*VK_USE_PLATFORM_WAYLAND_KHR*/ #ifdef VK_USE_PLATFORM_WIN32_KHR - vkGetPhysicalDeviceWin32PresentationSupportKHR = PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceWin32PresentationSupportKHR") : instance.getProcAddr( "vkGetPhysicalDeviceWin32PresentationSupportKHR")); + vkGetPhysicalDeviceWin32PresentationSupportKHR = PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR(instance.getProcAddr( "vkGetPhysicalDeviceWin32PresentationSupportKHR")); #endif /*VK_USE_PLATFORM_WIN32_KHR*/ #ifdef VK_USE_PLATFORM_XCB_KHR - vkGetPhysicalDeviceXcbPresentationSupportKHR = PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceXcbPresentationSupportKHR") : instance.getProcAddr( "vkGetPhysicalDeviceXcbPresentationSupportKHR")); + vkGetPhysicalDeviceXcbPresentationSupportKHR = PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR(instance.getProcAddr( "vkGetPhysicalDeviceXcbPresentationSupportKHR")); #endif /*VK_USE_PLATFORM_XCB_KHR*/ #ifdef VK_USE_PLATFORM_XLIB_KHR - vkGetPhysicalDeviceXlibPresentationSupportKHR = PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR(device ? device.getProcAddr( "vkGetPhysicalDeviceXlibPresentationSupportKHR") : instance.getProcAddr( "vkGetPhysicalDeviceXlibPresentationSupportKHR")); + vkGetPhysicalDeviceXlibPresentationSupportKHR = PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR(instance.getProcAddr( "vkGetPhysicalDeviceXlibPresentationSupportKHR")); #endif /*VK_USE_PLATFORM_XLIB_KHR*/ vkGetPipelineCacheData = PFN_vkGetPipelineCacheData(device ? device.getProcAddr( "vkGetPipelineCacheData") : instance.getProcAddr( "vkGetPipelineCacheData")); vkGetQueryPoolResults = PFN_vkGetQueryPoolResults(device ? device.getProcAddr( "vkGetQueryPoolResults") : instance.getProcAddr( "vkGetQueryPoolResults")); vkGetQueueCheckpointDataNV = PFN_vkGetQueueCheckpointDataNV(device ? device.getProcAddr( "vkGetQueueCheckpointDataNV") : instance.getProcAddr( "vkGetQueueCheckpointDataNV")); #ifdef VK_USE_PLATFORM_XLIB_XRANDR_NV - vkGetRandROutputDisplayEXT = PFN_vkGetRandROutputDisplayEXT(device ? device.getProcAddr( "vkGetRandROutputDisplayEXT") : instance.getProcAddr( "vkGetRandROutputDisplayEXT")); + vkGetRandROutputDisplayEXT = PFN_vkGetRandROutputDisplayEXT(instance.getProcAddr( "vkGetRandROutputDisplayEXT")); #endif /*VK_USE_PLATFORM_XLIB_XRANDR_NV*/ vkGetRefreshCycleDurationGOOGLE = PFN_vkGetRefreshCycleDurationGOOGLE(device ? device.getProcAddr( "vkGetRefreshCycleDurationGOOGLE") : instance.getProcAddr( "vkGetRefreshCycleDurationGOOGLE")); vkGetRenderAreaGranularity = PFN_vkGetRenderAreaGranularity(device ? device.getProcAddr( "vkGetRenderAreaGranularity") : instance.getProcAddr( "vkGetRenderAreaGranularity")); @@ -45161,7 +46910,7 @@ public: vkRegisterDeviceEventEXT = PFN_vkRegisterDeviceEventEXT(device ? device.getProcAddr( "vkRegisterDeviceEventEXT") : instance.getProcAddr( "vkRegisterDeviceEventEXT")); vkRegisterDisplayEventEXT = PFN_vkRegisterDisplayEventEXT(device ? device.getProcAddr( "vkRegisterDisplayEventEXT") : instance.getProcAddr( "vkRegisterDisplayEventEXT")); vkRegisterObjectsNVX = PFN_vkRegisterObjectsNVX(device ? device.getProcAddr( "vkRegisterObjectsNVX") : instance.getProcAddr( "vkRegisterObjectsNVX")); - vkReleaseDisplayEXT = PFN_vkReleaseDisplayEXT(device ? device.getProcAddr( "vkReleaseDisplayEXT") : instance.getProcAddr( "vkReleaseDisplayEXT")); + vkReleaseDisplayEXT = PFN_vkReleaseDisplayEXT(instance.getProcAddr( "vkReleaseDisplayEXT")); vkResetCommandBuffer = PFN_vkResetCommandBuffer(device ? device.getProcAddr( "vkResetCommandBuffer") : instance.getProcAddr( "vkResetCommandBuffer")); vkResetCommandPool = PFN_vkResetCommandPool(device ? device.getProcAddr( "vkResetCommandPool") : instance.getProcAddr( "vkResetCommandPool")); vkResetDescriptorPool = PFN_vkResetDescriptorPool(device ? device.getProcAddr( "vkResetDescriptorPool") : instance.getProcAddr( "vkResetDescriptorPool"));