From efe676ab66e7d01f14170db9003ca5bdd5a1a48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Wed, 13 Feb 2019 12:18:49 +0100 Subject: [PATCH] Handle aliased enum values with different extension tag as their base value. (#290) + update Vulkan-Docs to version 1.1.100. --- Vulkan-Docs | 2 +- VulkanHppGenerator.cpp | 43 +++++----- VulkanHppGenerator.hpp | 1 - vulkan/vulkan.hpp | 173 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 192 insertions(+), 27 deletions(-) diff --git a/Vulkan-Docs b/Vulkan-Docs index f1a7c4b..fcf5980 160000 --- a/Vulkan-Docs +++ b/Vulkan-Docs @@ -1 +1 @@ -Subproject commit f1a7c4b4f3031f985396f1aa617c51fd8a01c8c8 +Subproject commit fcf5980cf6acc620334f55b0cf2d162b05e0487a diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 89768d1..51770c2 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -35,6 +35,7 @@ std::string determineCommandName(std::string const& vulkanCommandName, std::stri std::set determineSkippedParams(size_t returnParamIndex, std::map const& vectorParamIndices); bool determineStructureChaining(std::string const& structType, std::set const& extendedStructs, std::map const& structureAliases); void enterProtect(std::ostream &os, std::string const& protect); +std::string findTag(std::set const& tags, std::string const& name, std::string const& postfix = ""); std::map getAttributes(tinyxml2::XMLElement const* element); std::vector getChildElements(tinyxml2::XMLElement const* element); std::string getEnumPostfix(std::string const& name, std::set const& tags, std::string & prefix); @@ -256,6 +257,12 @@ void enterProtect(std::ostream &os, std::string const& protect) } } +std::string findTag(std::set const& tags, std::string const& name, std::string const& postfix) +{ + auto tagIt = std::find_if(tags.begin(), tags.end(), [&name, &postfix](std::string const& t) { return endsWith(name, t + postfix); }); + return (tagIt != tags.end()) ? *tagIt : ""; +} + std::map getAttributes(tinyxml2::XMLElement const* element) { std::map attributes; @@ -1305,10 +1312,7 @@ std::vector VulkanHppGenerator::readCommandSuccessCodes(std::mapsecond, ','); for (auto & code : successCodes) { - // find the tag in the code - auto tagIt = std::find_if(m_tags.begin(), m_tags.end(), [&code](std::string const& t) { return endsWith(code, t); }); - std::string tag = (tagIt != m_tags.end()) ? *tagIt : ""; - + std::string tag = findTag(m_tags, code); // 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(stripPostfix(stripPrefix(code, "VK_"), tag)) + tag; } @@ -1386,8 +1390,7 @@ void VulkanHppGenerator::readEnum(tinyxml2::XMLElement const* element, EnumData checkElements(getChildElements(element), {}); std::string name = attributes.find("name")->second; - auto tagIt = std::find_if(m_tags.begin(), m_tags.end(), [&name, &postfix](std::string const& t) { return endsWith(name, t + postfix); }); - std::string tag = (tagIt != m_tags.end()) ? *tagIt : ""; + std::string tag = findTag(m_tags, name, postfix); auto aliasIt = attributes.find("alias"); if (aliasIt != attributes.end()) @@ -1641,7 +1644,18 @@ void VulkanHppGenerator::readExtensionRequireEnum(tinyxml2::XMLElement const* el if (aliasIt != attributes.end()) { checkAttributes(attributes, element->GetLineNum(), { { "alias",{} },{ "extends",{} },{ "name",{} } }, { { "comment",{} } }); - enumIt->second.addAlias(nameIt->second, aliasIt->second, bitmask, prefix, postfix, tag); + + // look for the aliased enum value + std::string alias = createEnumValueName(aliasIt->second, prefix, postfix, bitmask, findTag(m_tags, aliasIt->second)); + auto valueIt = std::find_if(enumIt->second.values.begin(), enumIt->second.values.end(), [&alias](std::pair const& value) { return value.second == alias; }); + assert(valueIt != enumIt->second.values.end()); + + std::string name = createEnumValueName(nameIt->second, prefix, postfix, bitmask, tag); + if (valueIt->second != name) + { + // only add an alias if it's different from the aliased name + enumIt->second.aliases.push_back(std::make_pair(nameIt->second, name)); + } } else { @@ -4100,21 +4114,6 @@ void VulkanHppGenerator::writeUniqueTypes(std::ostream &os, std::string const& p << "#endif /*VULKAN_HPP_NO_SMART_HANDLE*/" << std::endl; } -void VulkanHppGenerator::EnumData::addAlias(std::string const &valueName, std::string const& aliasName, bool bitmask, std::string const& prefix, std::string const& postfix, std::string const& tag) -{ - // look for the aliased enum value - std::string alias = createEnumValueName(aliasName, prefix, postfix, bitmask, tag); - auto valueIt = std::find_if(values.begin(), values.end(), [&alias](std::pair const& value) { return value.second == alias; }); - assert(valueIt != values.end()); - - std::string name = createEnumValueName(valueName, prefix, postfix, bitmask, tag); - if (valueIt->second != name) - { - // only add an alias if it's different from the aliased name - aliases.push_back(std::make_pair(valueName, name)); - } -} - void VulkanHppGenerator::EnumData::addEnumValue(std::string const &valueName, bool bitmask, std::string const& prefix, std::string const& postfix, std::string const& tag) { std::string translatedName = createEnumValueName(valueName, prefix, postfix, bitmask, tag); diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index ec92c87..f79085b 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -108,7 +108,6 @@ class VulkanHppGenerator struct EnumData { - void addAlias(std::string const& valueName, std::string const& aliasName, bool bitmask, std::string const& prefix, std::string const& postfix, std::string const& tag); void addEnumValue(std::string const& valueName, bool bitmask, std::string const& prefix, std::string const& postfix, std::string const& tag); std::vector> values; // pairs of vulkan enum value and corresponding vk::-namespace enum value diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 1dc5b1a..d6fc589 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -56,7 +56,7 @@ # define VULKAN_HPP_ASSERT assert #endif -static_assert( VK_HEADER_VERSION == 98 , "Wrong VK_HEADER_VERSION!" ); +static_assert( VK_HEADER_VERSION == 100 , "Wrong VK_HEADER_VERSION!" ); // 32-bit vulkan is not typesafe for handles, so don't allow copy constructors on this platform by default. // To enable this feature on 32-bit platforms please define VULKAN_HPP_TYPESAFE_CONVERSION @@ -3230,7 +3230,8 @@ namespace VULKAN_HPP_NAMESPACE { eNearest = VK_FILTER_NEAREST, eLinear = VK_FILTER_LINEAR, - eCubicIMG = VK_FILTER_CUBIC_IMG + eCubicIMG = VK_FILTER_CUBIC_IMG, + eCubicEXT = VK_FILTER_CUBIC_EXT }; VULKAN_HPP_INLINE std::string to_string( Filter value ) @@ -4892,6 +4893,8 @@ namespace VULKAN_HPP_NAMESPACE eAccelerationStructureInfoNV = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV, ePhysicalDeviceRepresentativeFragmentTestFeaturesNV = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV, ePipelineRepresentativeFragmentTestStateCreateInfoNV = VK_STRUCTURE_TYPE_PIPELINE_REPRESENTATIVE_FRAGMENT_TEST_STATE_CREATE_INFO_NV, + ePhysicalDeviceImageViewImageFormatInfoEXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT, + eFilterCubicImageViewImageFormatPropertiesEXT = VK_STRUCTURE_TYPE_FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT, eDeviceQueueGlobalPriorityCreateInfoEXT = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT, ePhysicalDevice8BitStorageFeaturesKHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR, eImportMemoryHostPointerInfoEXT = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT, @@ -4927,6 +4930,7 @@ namespace VULKAN_HPP_NAMESPACE ePhysicalDeviceMemoryBudgetPropertiesEXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT, ePhysicalDeviceMemoryPriorityFeaturesEXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT, eMemoryPriorityAllocateInfoEXT = VK_STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT, + ePhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV, ePhysicalDeviceBufferAddressFeaturesEXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT, eBufferDeviceAddressInfoEXT = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_EXT, eBufferDeviceAddressCreateInfoEXT = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT, @@ -5271,6 +5275,8 @@ namespace VULKAN_HPP_NAMESPACE case StructureType::eAccelerationStructureInfoNV : return "AccelerationStructureInfoNV"; case StructureType::ePhysicalDeviceRepresentativeFragmentTestFeaturesNV : return "PhysicalDeviceRepresentativeFragmentTestFeaturesNV"; case StructureType::ePipelineRepresentativeFragmentTestStateCreateInfoNV : return "PipelineRepresentativeFragmentTestStateCreateInfoNV"; + case StructureType::ePhysicalDeviceImageViewImageFormatInfoEXT : return "PhysicalDeviceImageViewImageFormatInfoEXT"; + case StructureType::eFilterCubicImageViewImageFormatPropertiesEXT : return "FilterCubicImageViewImageFormatPropertiesEXT"; case StructureType::eDeviceQueueGlobalPriorityCreateInfoEXT : return "DeviceQueueGlobalPriorityCreateInfoEXT"; case StructureType::ePhysicalDevice8BitStorageFeaturesKHR : return "PhysicalDevice8BitStorageFeaturesKHR"; case StructureType::eImportMemoryHostPointerInfoEXT : return "ImportMemoryHostPointerInfoEXT"; @@ -5306,6 +5312,7 @@ namespace VULKAN_HPP_NAMESPACE case StructureType::ePhysicalDeviceMemoryBudgetPropertiesEXT : return "PhysicalDeviceMemoryBudgetPropertiesEXT"; case StructureType::ePhysicalDeviceMemoryPriorityFeaturesEXT : return "PhysicalDeviceMemoryPriorityFeaturesEXT"; case StructureType::eMemoryPriorityAllocateInfoEXT : return "MemoryPriorityAllocateInfoEXT"; + case StructureType::ePhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV : return "PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV"; case StructureType::ePhysicalDeviceBufferAddressFeaturesEXT : return "PhysicalDeviceBufferAddressFeaturesEXT"; case StructureType::eBufferDeviceAddressInfoEXT : return "BufferDeviceAddressInfoEXT"; case StructureType::eBufferDeviceAddressCreateInfoEXT : return "BufferDeviceAddressCreateInfoEXT"; @@ -7517,7 +7524,8 @@ namespace VULKAN_HPP_NAMESPACE eSampledImageYcbcrConversionChromaReconstructionExplicitKHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR, eSampledImageYcbcrConversionChromaReconstructionExplicitForceableKHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR, eDisjointKHR = VK_FORMAT_FEATURE_DISJOINT_BIT_KHR, - eCositedChromaSamplesKHR = VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR + eCositedChromaSamplesKHR = VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR, + eSampledImageFilterCubicEXT = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT }; VULKAN_HPP_INLINE std::string to_string( FormatFeatureFlagBits value ) @@ -28188,6 +28196,41 @@ namespace VULKAN_HPP_NAMESPACE static_assert( sizeof( FenceGetWin32HandleInfoKHR ) == sizeof( VkFenceGetWin32HandleInfoKHR ), "struct and wrapper have different size!" ); #endif /*VK_USE_PLATFORM_WIN32_KHR*/ + struct FilterCubicImageViewImageFormatPropertiesEXT + { + operator VkFilterCubicImageViewImageFormatPropertiesEXT const&() const + { + return *reinterpret_cast( this ); + } + + operator VkFilterCubicImageViewImageFormatPropertiesEXT &() + { + return *reinterpret_cast( this ); + } + + bool operator==( FilterCubicImageViewImageFormatPropertiesEXT const& rhs ) const + { + return ( sType == rhs.sType ) + && ( pNext == rhs.pNext ) + && ( filterCubic == rhs.filterCubic ) + && ( filterCubicMinmax == rhs.filterCubicMinmax ); + } + + bool operator!=( FilterCubicImageViewImageFormatPropertiesEXT const& rhs ) const + { + return !operator==( rhs ); + } + + private: + StructureType sType = StructureType::eFilterCubicImageViewImageFormatPropertiesEXT; + + public: + void* pNext = nullptr; + Bool32 filterCubic; + Bool32 filterCubicMinmax; + }; + static_assert( sizeof( FilterCubicImageViewImageFormatPropertiesEXT ) == sizeof( VkFilterCubicImageViewImageFormatPropertiesEXT ), "struct and wrapper have different size!" ); + struct FormatProperties { operator VkFormatProperties const&() const @@ -35256,6 +35299,66 @@ namespace VULKAN_HPP_NAMESPACE }; static_assert( sizeof( PhysicalDeviceCornerSampledImageFeaturesNV ) == sizeof( VkPhysicalDeviceCornerSampledImageFeaturesNV ), "struct and wrapper have different size!" ); + struct PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV + { + PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV( Bool32 dedicatedAllocationImageAliasing_ = 0 ) + : dedicatedAllocationImageAliasing( dedicatedAllocationImageAliasing_ ) + {} + + PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV( VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV const & rhs ) + { + memcpy( this, &rhs, sizeof( PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV ) ); + } + + PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV& operator=( VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV const & rhs ) + { + memcpy( this, &rhs, sizeof( PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV ) ); + return *this; + } + + PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV & setPNext( void* pNext_ ) + { + pNext = pNext_; + return *this; + } + + PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV & setDedicatedAllocationImageAliasing( Bool32 dedicatedAllocationImageAliasing_ ) + { + dedicatedAllocationImageAliasing = dedicatedAllocationImageAliasing_; + return *this; + } + + operator VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV const&() const + { + return *reinterpret_cast( this ); + } + + operator VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV &() + { + return *reinterpret_cast( this ); + } + + bool operator==( PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV const& rhs ) const + { + return ( sType == rhs.sType ) + && ( pNext == rhs.pNext ) + && ( dedicatedAllocationImageAliasing == rhs.dedicatedAllocationImageAliasing ); + } + + bool operator!=( PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV const& rhs ) const + { + return !operator==( rhs ); + } + + private: + StructureType sType = StructureType::ePhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV; + + public: + void* pNext = nullptr; + Bool32 dedicatedAllocationImageAliasing; + }; + static_assert( sizeof( PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV ) == sizeof( VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV ), "struct and wrapper have different size!" ); + struct PhysicalDeviceDepthStencilResolvePropertiesKHR { operator VkPhysicalDeviceDepthStencilResolvePropertiesKHR const&() const @@ -36644,6 +36747,66 @@ namespace VULKAN_HPP_NAMESPACE }; static_assert( sizeof( PhysicalDeviceImageFormatInfo2 ) == sizeof( VkPhysicalDeviceImageFormatInfo2 ), "struct and wrapper have different size!" ); + struct PhysicalDeviceImageViewImageFormatInfoEXT + { + PhysicalDeviceImageViewImageFormatInfoEXT( ImageViewType imageViewType_ = ImageViewType::e1D ) + : imageViewType( imageViewType_ ) + {} + + PhysicalDeviceImageViewImageFormatInfoEXT( VkPhysicalDeviceImageViewImageFormatInfoEXT const & rhs ) + { + memcpy( this, &rhs, sizeof( PhysicalDeviceImageViewImageFormatInfoEXT ) ); + } + + PhysicalDeviceImageViewImageFormatInfoEXT& operator=( VkPhysicalDeviceImageViewImageFormatInfoEXT const & rhs ) + { + memcpy( this, &rhs, sizeof( PhysicalDeviceImageViewImageFormatInfoEXT ) ); + return *this; + } + + PhysicalDeviceImageViewImageFormatInfoEXT & setPNext( void* pNext_ ) + { + pNext = pNext_; + return *this; + } + + PhysicalDeviceImageViewImageFormatInfoEXT & setImageViewType( ImageViewType imageViewType_ ) + { + imageViewType = imageViewType_; + return *this; + } + + operator VkPhysicalDeviceImageViewImageFormatInfoEXT const&() const + { + return *reinterpret_cast( this ); + } + + operator VkPhysicalDeviceImageViewImageFormatInfoEXT &() + { + return *reinterpret_cast( this ); + } + + bool operator==( PhysicalDeviceImageViewImageFormatInfoEXT const& rhs ) const + { + return ( sType == rhs.sType ) + && ( pNext == rhs.pNext ) + && ( imageViewType == rhs.imageViewType ); + } + + bool operator!=( PhysicalDeviceImageViewImageFormatInfoEXT const& rhs ) const + { + return !operator==( rhs ); + } + + private: + StructureType sType = StructureType::ePhysicalDeviceImageViewImageFormatInfoEXT; + + public: + void* pNext = nullptr; + ImageViewType imageViewType; + }; + static_assert( sizeof( PhysicalDeviceImageViewImageFormatInfoEXT ) == sizeof( VkPhysicalDeviceImageViewImageFormatInfoEXT ), "struct and wrapper have different size!" ); + struct PhysicalDeviceInlineUniformBlockFeaturesEXT { PhysicalDeviceInlineUniformBlockFeaturesEXT( Bool32 inlineUniformBlock_ = 0, @@ -53431,6 +53594,7 @@ namespace VULKAN_HPP_NAMESPACE template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; + template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; @@ -53475,6 +53639,8 @@ namespace VULKAN_HPP_NAMESPACE template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; + template <> struct isStructureChainValid{ enum { value = true }; }; + template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; @@ -53496,6 +53662,7 @@ namespace VULKAN_HPP_NAMESPACE template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; + template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; }; template <> struct isStructureChainValid{ enum { value = true }; };