From a49fd51629f4c8a83531602bb9a2364a9e5a8be8 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Wed, 5 Oct 2022 16:58:40 +0200 Subject: [PATCH] Minor cleanup on bitmask generation. --- VulkanHppGenerator.cpp | 26 ++++++++++++++++---------- VulkanHppGenerator.hpp | 4 ++-- vulkan/vulkan_enums.hpp | 36 +++++------------------------------- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 2d92561..3d92b20 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -120,8 +120,7 @@ namespace VULKAN_HPP_NAMESPACE }; ${enums} ${indexTypeTraits} -${bitmasks} -} // namespace VULKAN_HPP_NAMESPACE +${bitmasks}} // namespace VULKAN_HPP_NAMESPACE #endif )"; @@ -2093,7 +2092,7 @@ ${basetypes} return replaceWithMap( basetypesTemplate, { { "basetypes", basetypes } } ); } -std::string VulkanHppGenerator::generateBitmask( std::map::const_iterator bitmaskIt ) const +std::string VulkanHppGenerator::generateBitmask( std::map::const_iterator bitmaskIt, std::string const & surroundingProtect ) const { auto bitmaskBitsIt = m_enums.find( bitmaskIt->second.requirements ); assert( bitmaskBitsIt != m_enums.end() ); @@ -2108,7 +2107,7 @@ std::string VulkanHppGenerator::generateBitmask( std::mapsecond.values.empty() ) { - str += alias + "\n"; + str += alias; } else { @@ -2140,15 +2139,22 @@ std::string VulkanHppGenerator::generateBitmask( std::mapsecond.values ) { - auto [enter, leave] = generateProtection( getProtect( value ) ); + // determine the values protect, if any + std::string valueProtect = getProtect( value ); + + // if the value's protect differs from the surrounding protect, generate protection code + std::string enter, leave; + if ( !valueProtect.empty() && ( valueProtect != surroundingProtect ) ) + { + tie( enter, leave ) = generateProtection( valueProtect ); + } std::string valueName = generateEnumValueName( bitmaskBitsIt->first, value.name, true, m_tags ); allFlags += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + " " + ( encounteredFlag ? "| " : " " ) + bitmaskIt->second.type + "( " + enumName + "::" + valueName + " )"; @@ -2178,8 +2184,7 @@ std::string VulkanHppGenerator::generateBitmasks() const //=== BITMASKs === //================ -${bitmasks} -)"; +${bitmasks})"; std::string bitmasks; std::set listedBitmasks; @@ -2198,6 +2203,7 @@ ${bitmasks} std::string VulkanHppGenerator::generateBitmasks( std::vector const & requireData, std::set & listedBitmasks, std::string const & title ) const { + std::string surroundingProtect = getProtectFromTitle( title ); std::string str; for ( auto const & require : requireData ) { @@ -2207,7 +2213,7 @@ std::string if ( ( bitmaskIt != m_bitmasks.end() ) && ( listedBitmasks.find( type ) == listedBitmasks.end() ) ) { listedBitmasks.insert( type ); - str += generateBitmask( bitmaskIt ); + str += generateBitmask( bitmaskIt, surroundingProtect ); } } } diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 8222b81..aba46b4 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -455,8 +455,8 @@ private: bool chained, bool raii ) const; std::string generateBaseTypes() const; - std::string generateBitmask( std::map::const_iterator bitmaskIt ) const; - std::string generateBitmasks() const; + std::string generateBitmask( std::map::const_iterator bitmaskIt, std::string const & surroundingProtect ) const; + std::string generateBitmasks() const; std::string generateBitmasks( std::vector const & requireData, std::set & listedBitmasks, std::string const & title ) const; std::string generateBitmasksToString() const; std::string generateBitmasksToString( std::vector const & requireData, std::set & listedBitmasks, std::string const & title ) const; diff --git a/vulkan/vulkan_enums.hpp b/vulkan/vulkan_enums.hpp index fae22aa..738c154 100644 --- a/vulkan/vulkan_enums.hpp +++ b/vulkan/vulkan_enums.hpp @@ -7062,35 +7062,30 @@ namespace VULKAN_HPP_NAMESPACE //=== VK_KHR_xlib_surface === using XlibSurfaceCreateFlagsKHR = Flags; - #endif /*VK_USE_PLATFORM_XLIB_KHR*/ #if defined( VK_USE_PLATFORM_XCB_KHR ) //=== VK_KHR_xcb_surface === using XcbSurfaceCreateFlagsKHR = Flags; - #endif /*VK_USE_PLATFORM_XCB_KHR*/ #if defined( VK_USE_PLATFORM_WAYLAND_KHR ) //=== VK_KHR_wayland_surface === using WaylandSurfaceCreateFlagsKHR = Flags; - #endif /*VK_USE_PLATFORM_WAYLAND_KHR*/ #if defined( VK_USE_PLATFORM_ANDROID_KHR ) //=== VK_KHR_android_surface === using AndroidSurfaceCreateFlagsKHR = Flags; - #endif /*VK_USE_PLATFORM_ANDROID_KHR*/ #if defined( VK_USE_PLATFORM_WIN32_KHR ) //=== VK_KHR_win32_surface === using Win32SurfaceCreateFlagsKHR = Flags; - #endif /*VK_USE_PLATFORM_WIN32_KHR*/ //=== VK_EXT_debug_report === @@ -7137,11 +7132,9 @@ namespace VULKAN_HPP_NAMESPACE { enum : VkFlags { - allFlags = VkFlags( VideoCodecOperationFlagBitsKHR::eNone ) -# if defined( VK_ENABLE_BETA_EXTENSIONS ) - | VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH264EXT ) | VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH265EXT ) | - VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH264EXT ) | VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH265EXT ) -# endif /*VK_ENABLE_BETA_EXTENSIONS*/ + allFlags = VkFlags( VideoCodecOperationFlagBitsKHR::eNone ) | VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH264EXT ) | + VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH265EXT ) | VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH264EXT ) | + VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH265EXT ) }; }; @@ -7320,10 +7313,8 @@ namespace VULKAN_HPP_NAMESPACE { enum : VkFlags { - allFlags = VkFlags( VideoCodingControlFlagBitsKHR::eReset ) -# if defined( VK_ENABLE_BETA_EXTENSIONS ) - | VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControl ) | VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControlLayer ) -# endif /*VK_ENABLE_BETA_EXTENSIONS*/ + allFlags = VkFlags( VideoCodingControlFlagBitsKHR::eReset ) | VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControl ) | + VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControlLayer ) }; }; @@ -7349,7 +7340,6 @@ namespace VULKAN_HPP_NAMESPACE { return ~( VideoCodingControlFlagsKHR( bits ) ); } - #endif /*VK_ENABLE_BETA_EXTENSIONS*/ #if defined( VK_ENABLE_BETA_EXTENSIONS ) @@ -7425,7 +7415,6 @@ namespace VULKAN_HPP_NAMESPACE } using VideoDecodeFlagsKHR = Flags; - #endif /*VK_ENABLE_BETA_EXTENSIONS*/ //=== VK_EXT_transform_feedback === @@ -7551,7 +7540,6 @@ namespace VULKAN_HPP_NAMESPACE { return ~( VideoEncodeH264OutputModeFlagsEXT( bits ) ); } - #endif /*VK_ENABLE_BETA_EXTENSIONS*/ #if defined( VK_ENABLE_BETA_EXTENSIONS ) @@ -7745,7 +7733,6 @@ namespace VULKAN_HPP_NAMESPACE { return ~( VideoEncodeH265TransformBlockSizeFlagsEXT( bits ) ); } - #endif /*VK_ENABLE_BETA_EXTENSIONS*/ #if defined( VK_ENABLE_BETA_EXTENSIONS ) @@ -7786,14 +7773,12 @@ namespace VULKAN_HPP_NAMESPACE { return ~( VideoDecodeH264PictureLayoutFlagsEXT( bits ) ); } - #endif /*VK_ENABLE_BETA_EXTENSIONS*/ #if defined( VK_USE_PLATFORM_GGP ) //=== VK_GGP_stream_descriptor_surface === using StreamDescriptorSurfaceCreateFlagsGGP = Flags; - #endif /*VK_USE_PLATFORM_GGP*/ //=== VK_NV_external_memory_capabilities === @@ -7872,7 +7857,6 @@ namespace VULKAN_HPP_NAMESPACE //=== VK_NN_vi_surface === using ViSurfaceCreateFlagsNN = Flags; - #endif /*VK_USE_PLATFORM_VI_NN*/ //=== VK_EXT_conditional_rendering === @@ -8003,14 +7987,12 @@ namespace VULKAN_HPP_NAMESPACE //=== VK_MVK_ios_surface === using IOSSurfaceCreateFlagsMVK = Flags; - #endif /*VK_USE_PLATFORM_IOS_MVK*/ #if defined( VK_USE_PLATFORM_MACOS_MVK ) //=== VK_MVK_macos_surface === using MacOSSurfaceCreateFlagsMVK = Flags; - #endif /*VK_USE_PLATFORM_MACOS_MVK*/ //=== VK_EXT_debug_utils === @@ -8257,14 +8239,12 @@ namespace VULKAN_HPP_NAMESPACE //=== VK_FUCHSIA_imagepipe_surface === using ImagePipeSurfaceCreateFlagsFUCHSIA = Flags; - #endif /*VK_USE_PLATFORM_FUCHSIA*/ #if defined( VK_USE_PLATFORM_METAL_EXT ) //=== VK_EXT_metal_surface === using MetalSurfaceCreateFlagsEXT = Flags; - #endif /*VK_USE_PLATFORM_METAL_EXT*/ //=== VK_AMD_shader_core_properties2 === @@ -8497,7 +8477,6 @@ namespace VULKAN_HPP_NAMESPACE { return ~( VideoEncodeRateControlModeFlagsKHR( bits ) ); } - #endif /*VK_ENABLE_BETA_EXTENSIONS*/ //=== VK_NV_device_diagnostics_config === @@ -8576,7 +8555,6 @@ namespace VULKAN_HPP_NAMESPACE { return ~( ExportMetalObjectTypeFlagsEXT( bits ) ); } - #endif /*VK_USE_PLATFORM_METAL_EXT*/ //=== VK_EXT_graphics_pipeline_library === @@ -8710,7 +8688,6 @@ namespace VULKAN_HPP_NAMESPACE //=== VK_EXT_directfb_surface === using DirectFBSurfaceCreateFlagsEXT = Flags; - #endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/ //=== VK_EXT_device_address_binding_report === @@ -8789,14 +8766,12 @@ namespace VULKAN_HPP_NAMESPACE { return ~( ImageConstraintsInfoFlagsFUCHSIA( bits ) ); } - #endif /*VK_USE_PLATFORM_FUCHSIA*/ #if defined( VK_USE_PLATFORM_SCREEN_QNX ) //=== VK_QNX_screen_surface === using ScreenSurfaceCreateFlagsQNX = Flags; - #endif /*VK_USE_PLATFORM_SCREEN_QNX*/ //=== VK_EXT_opacity_micromap === @@ -9007,6 +8982,5 @@ namespace VULKAN_HPP_NAMESPACE { return ~( OpticalFlowExecuteFlagsNV( bits ) ); } - } // namespace VULKAN_HPP_NAMESPACE #endif