Minor cleanup on bitmask generation.

This commit is contained in:
asuessenbach 2022-10-05 16:58:40 +02:00
parent 231c69b507
commit a49fd51629
3 changed files with 23 additions and 43 deletions

View File

@ -120,8 +120,7 @@ namespace VULKAN_HPP_NAMESPACE
}; };
${enums} ${enums}
${indexTypeTraits} ${indexTypeTraits}
${bitmasks} ${bitmasks}} // namespace VULKAN_HPP_NAMESPACE
} // namespace VULKAN_HPP_NAMESPACE
#endif #endif
)"; )";
@ -2093,7 +2092,7 @@ ${basetypes}
return replaceWithMap( basetypesTemplate, { { "basetypes", basetypes } } ); return replaceWithMap( basetypesTemplate, { { "basetypes", basetypes } } );
} }
std::string VulkanHppGenerator::generateBitmask( std::map<std::string, BitmaskData>::const_iterator bitmaskIt ) const std::string VulkanHppGenerator::generateBitmask( std::map<std::string, BitmaskData>::const_iterator bitmaskIt, std::string const & surroundingProtect ) const
{ {
auto bitmaskBitsIt = m_enums.find( bitmaskIt->second.requirements ); auto bitmaskBitsIt = m_enums.find( bitmaskIt->second.requirements );
assert( bitmaskBitsIt != m_enums.end() ); assert( bitmaskBitsIt != m_enums.end() );
@ -2108,7 +2107,7 @@ std::string VulkanHppGenerator::generateBitmask( std::map<std::string, BitmaskDa
if ( bitmaskBitsIt->second.values.empty() ) if ( bitmaskBitsIt->second.values.empty() )
{ {
str += alias + "\n"; str += alias;
} }
else else
{ {
@ -2140,15 +2139,22 @@ std::string VulkanHppGenerator::generateBitmask( std::map<std::string, BitmaskDa
{ {
return ~( ${bitmaskName}( bits ) ); return ~( ${bitmaskName}( bits ) );
} }
${alias} ${alias})";
)";
std::string allFlags; std::string allFlags;
bool encounteredFlag = false; bool encounteredFlag = false;
std::string previousEnter, previousLeave; std::string previousEnter, previousLeave;
for ( auto const & value : bitmaskBitsIt->second.values ) for ( auto const & value : bitmaskBitsIt->second.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 ); std::string valueName = generateEnumValueName( bitmaskBitsIt->first, value.name, true, m_tags );
allFlags += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + " " + ( encounteredFlag ? "| " : " " ) + allFlags += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + " " + ( encounteredFlag ? "| " : " " ) +
bitmaskIt->second.type + "( " + enumName + "::" + valueName + " )"; bitmaskIt->second.type + "( " + enumName + "::" + valueName + " )";
@ -2178,8 +2184,7 @@ std::string VulkanHppGenerator::generateBitmasks() const
//=== BITMASKs === //=== BITMASKs ===
//================ //================
${bitmasks} ${bitmasks})";
)";
std::string bitmasks; std::string bitmasks;
std::set<std::string> listedBitmasks; std::set<std::string> listedBitmasks;
@ -2198,6 +2203,7 @@ ${bitmasks}
std::string std::string
VulkanHppGenerator::generateBitmasks( std::vector<RequireData> const & requireData, std::set<std::string> & listedBitmasks, std::string const & title ) const VulkanHppGenerator::generateBitmasks( std::vector<RequireData> const & requireData, std::set<std::string> & listedBitmasks, std::string const & title ) const
{ {
std::string surroundingProtect = getProtectFromTitle( title );
std::string str; std::string str;
for ( auto const & require : requireData ) for ( auto const & require : requireData )
{ {
@ -2207,7 +2213,7 @@ std::string
if ( ( bitmaskIt != m_bitmasks.end() ) && ( listedBitmasks.find( type ) == listedBitmasks.end() ) ) if ( ( bitmaskIt != m_bitmasks.end() ) && ( listedBitmasks.find( type ) == listedBitmasks.end() ) )
{ {
listedBitmasks.insert( type ); listedBitmasks.insert( type );
str += generateBitmask( bitmaskIt ); str += generateBitmask( bitmaskIt, surroundingProtect );
} }
} }
} }

View File

@ -455,8 +455,8 @@ private:
bool chained, bool chained,
bool raii ) const; bool raii ) const;
std::string generateBaseTypes() const; std::string generateBaseTypes() const;
std::string generateBitmask( std::map<std::string, BitmaskData>::const_iterator bitmaskIt ) const; std::string generateBitmask( std::map<std::string, BitmaskData>::const_iterator bitmaskIt, std::string const & surroundingProtect ) const;
std::string generateBitmasks() const; std::string generateBitmasks() const;
std::string generateBitmasks( std::vector<RequireData> const & requireData, std::set<std::string> & listedBitmasks, std::string const & title ) const; std::string generateBitmasks( std::vector<RequireData> const & requireData, std::set<std::string> & listedBitmasks, std::string const & title ) const;
std::string generateBitmasksToString() const; std::string generateBitmasksToString() const;
std::string generateBitmasksToString( std::vector<RequireData> const & requireData, std::set<std::string> & listedBitmasks, std::string const & title ) const; std::string generateBitmasksToString( std::vector<RequireData> const & requireData, std::set<std::string> & listedBitmasks, std::string const & title ) const;

View File

@ -7062,35 +7062,30 @@ namespace VULKAN_HPP_NAMESPACE
//=== VK_KHR_xlib_surface === //=== VK_KHR_xlib_surface ===
using XlibSurfaceCreateFlagsKHR = Flags<XlibSurfaceCreateFlagBitsKHR>; using XlibSurfaceCreateFlagsKHR = Flags<XlibSurfaceCreateFlagBitsKHR>;
#endif /*VK_USE_PLATFORM_XLIB_KHR*/ #endif /*VK_USE_PLATFORM_XLIB_KHR*/
#if defined( VK_USE_PLATFORM_XCB_KHR ) #if defined( VK_USE_PLATFORM_XCB_KHR )
//=== VK_KHR_xcb_surface === //=== VK_KHR_xcb_surface ===
using XcbSurfaceCreateFlagsKHR = Flags<XcbSurfaceCreateFlagBitsKHR>; using XcbSurfaceCreateFlagsKHR = Flags<XcbSurfaceCreateFlagBitsKHR>;
#endif /*VK_USE_PLATFORM_XCB_KHR*/ #endif /*VK_USE_PLATFORM_XCB_KHR*/
#if defined( VK_USE_PLATFORM_WAYLAND_KHR ) #if defined( VK_USE_PLATFORM_WAYLAND_KHR )
//=== VK_KHR_wayland_surface === //=== VK_KHR_wayland_surface ===
using WaylandSurfaceCreateFlagsKHR = Flags<WaylandSurfaceCreateFlagBitsKHR>; using WaylandSurfaceCreateFlagsKHR = Flags<WaylandSurfaceCreateFlagBitsKHR>;
#endif /*VK_USE_PLATFORM_WAYLAND_KHR*/ #endif /*VK_USE_PLATFORM_WAYLAND_KHR*/
#if defined( VK_USE_PLATFORM_ANDROID_KHR ) #if defined( VK_USE_PLATFORM_ANDROID_KHR )
//=== VK_KHR_android_surface === //=== VK_KHR_android_surface ===
using AndroidSurfaceCreateFlagsKHR = Flags<AndroidSurfaceCreateFlagBitsKHR>; using AndroidSurfaceCreateFlagsKHR = Flags<AndroidSurfaceCreateFlagBitsKHR>;
#endif /*VK_USE_PLATFORM_ANDROID_KHR*/ #endif /*VK_USE_PLATFORM_ANDROID_KHR*/
#if defined( VK_USE_PLATFORM_WIN32_KHR ) #if defined( VK_USE_PLATFORM_WIN32_KHR )
//=== VK_KHR_win32_surface === //=== VK_KHR_win32_surface ===
using Win32SurfaceCreateFlagsKHR = Flags<Win32SurfaceCreateFlagBitsKHR>; using Win32SurfaceCreateFlagsKHR = Flags<Win32SurfaceCreateFlagBitsKHR>;
#endif /*VK_USE_PLATFORM_WIN32_KHR*/ #endif /*VK_USE_PLATFORM_WIN32_KHR*/
//=== VK_EXT_debug_report === //=== VK_EXT_debug_report ===
@ -7137,11 +7132,9 @@ namespace VULKAN_HPP_NAMESPACE
{ {
enum : VkFlags enum : VkFlags
{ {
allFlags = VkFlags( VideoCodecOperationFlagBitsKHR::eNone ) allFlags = VkFlags( VideoCodecOperationFlagBitsKHR::eNone ) | VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH264EXT ) |
# if defined( VK_ENABLE_BETA_EXTENSIONS ) VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH265EXT ) | VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH264EXT ) |
| VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH264EXT ) | VkFlags( VideoCodecOperationFlagBitsKHR::eEncodeH265EXT ) | VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH265EXT )
VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH264EXT ) | VkFlags( VideoCodecOperationFlagBitsKHR::eDecodeH265EXT )
# endif /*VK_ENABLE_BETA_EXTENSIONS*/
}; };
}; };
@ -7320,10 +7313,8 @@ namespace VULKAN_HPP_NAMESPACE
{ {
enum : VkFlags enum : VkFlags
{ {
allFlags = VkFlags( VideoCodingControlFlagBitsKHR::eReset ) allFlags = VkFlags( VideoCodingControlFlagBitsKHR::eReset ) | VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControl ) |
# if defined( VK_ENABLE_BETA_EXTENSIONS ) VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControlLayer )
| VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControl ) | VkFlags( VideoCodingControlFlagBitsKHR::eEncodeRateControlLayer )
# endif /*VK_ENABLE_BETA_EXTENSIONS*/
}; };
}; };
@ -7349,7 +7340,6 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( VideoCodingControlFlagsKHR( bits ) ); return ~( VideoCodingControlFlagsKHR( bits ) );
} }
#endif /*VK_ENABLE_BETA_EXTENSIONS*/ #endif /*VK_ENABLE_BETA_EXTENSIONS*/
#if defined( VK_ENABLE_BETA_EXTENSIONS ) #if defined( VK_ENABLE_BETA_EXTENSIONS )
@ -7425,7 +7415,6 @@ namespace VULKAN_HPP_NAMESPACE
} }
using VideoDecodeFlagsKHR = Flags<VideoDecodeFlagBitsKHR>; using VideoDecodeFlagsKHR = Flags<VideoDecodeFlagBitsKHR>;
#endif /*VK_ENABLE_BETA_EXTENSIONS*/ #endif /*VK_ENABLE_BETA_EXTENSIONS*/
//=== VK_EXT_transform_feedback === //=== VK_EXT_transform_feedback ===
@ -7551,7 +7540,6 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( VideoEncodeH264OutputModeFlagsEXT( bits ) ); return ~( VideoEncodeH264OutputModeFlagsEXT( bits ) );
} }
#endif /*VK_ENABLE_BETA_EXTENSIONS*/ #endif /*VK_ENABLE_BETA_EXTENSIONS*/
#if defined( VK_ENABLE_BETA_EXTENSIONS ) #if defined( VK_ENABLE_BETA_EXTENSIONS )
@ -7745,7 +7733,6 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( VideoEncodeH265TransformBlockSizeFlagsEXT( bits ) ); return ~( VideoEncodeH265TransformBlockSizeFlagsEXT( bits ) );
} }
#endif /*VK_ENABLE_BETA_EXTENSIONS*/ #endif /*VK_ENABLE_BETA_EXTENSIONS*/
#if defined( VK_ENABLE_BETA_EXTENSIONS ) #if defined( VK_ENABLE_BETA_EXTENSIONS )
@ -7786,14 +7773,12 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( VideoDecodeH264PictureLayoutFlagsEXT( bits ) ); return ~( VideoDecodeH264PictureLayoutFlagsEXT( bits ) );
} }
#endif /*VK_ENABLE_BETA_EXTENSIONS*/ #endif /*VK_ENABLE_BETA_EXTENSIONS*/
#if defined( VK_USE_PLATFORM_GGP ) #if defined( VK_USE_PLATFORM_GGP )
//=== VK_GGP_stream_descriptor_surface === //=== VK_GGP_stream_descriptor_surface ===
using StreamDescriptorSurfaceCreateFlagsGGP = Flags<StreamDescriptorSurfaceCreateFlagBitsGGP>; using StreamDescriptorSurfaceCreateFlagsGGP = Flags<StreamDescriptorSurfaceCreateFlagBitsGGP>;
#endif /*VK_USE_PLATFORM_GGP*/ #endif /*VK_USE_PLATFORM_GGP*/
//=== VK_NV_external_memory_capabilities === //=== VK_NV_external_memory_capabilities ===
@ -7872,7 +7857,6 @@ namespace VULKAN_HPP_NAMESPACE
//=== VK_NN_vi_surface === //=== VK_NN_vi_surface ===
using ViSurfaceCreateFlagsNN = Flags<ViSurfaceCreateFlagBitsNN>; using ViSurfaceCreateFlagsNN = Flags<ViSurfaceCreateFlagBitsNN>;
#endif /*VK_USE_PLATFORM_VI_NN*/ #endif /*VK_USE_PLATFORM_VI_NN*/
//=== VK_EXT_conditional_rendering === //=== VK_EXT_conditional_rendering ===
@ -8003,14 +7987,12 @@ namespace VULKAN_HPP_NAMESPACE
//=== VK_MVK_ios_surface === //=== VK_MVK_ios_surface ===
using IOSSurfaceCreateFlagsMVK = Flags<IOSSurfaceCreateFlagBitsMVK>; using IOSSurfaceCreateFlagsMVK = Flags<IOSSurfaceCreateFlagBitsMVK>;
#endif /*VK_USE_PLATFORM_IOS_MVK*/ #endif /*VK_USE_PLATFORM_IOS_MVK*/
#if defined( VK_USE_PLATFORM_MACOS_MVK ) #if defined( VK_USE_PLATFORM_MACOS_MVK )
//=== VK_MVK_macos_surface === //=== VK_MVK_macos_surface ===
using MacOSSurfaceCreateFlagsMVK = Flags<MacOSSurfaceCreateFlagBitsMVK>; using MacOSSurfaceCreateFlagsMVK = Flags<MacOSSurfaceCreateFlagBitsMVK>;
#endif /*VK_USE_PLATFORM_MACOS_MVK*/ #endif /*VK_USE_PLATFORM_MACOS_MVK*/
//=== VK_EXT_debug_utils === //=== VK_EXT_debug_utils ===
@ -8257,14 +8239,12 @@ namespace VULKAN_HPP_NAMESPACE
//=== VK_FUCHSIA_imagepipe_surface === //=== VK_FUCHSIA_imagepipe_surface ===
using ImagePipeSurfaceCreateFlagsFUCHSIA = Flags<ImagePipeSurfaceCreateFlagBitsFUCHSIA>; using ImagePipeSurfaceCreateFlagsFUCHSIA = Flags<ImagePipeSurfaceCreateFlagBitsFUCHSIA>;
#endif /*VK_USE_PLATFORM_FUCHSIA*/ #endif /*VK_USE_PLATFORM_FUCHSIA*/
#if defined( VK_USE_PLATFORM_METAL_EXT ) #if defined( VK_USE_PLATFORM_METAL_EXT )
//=== VK_EXT_metal_surface === //=== VK_EXT_metal_surface ===
using MetalSurfaceCreateFlagsEXT = Flags<MetalSurfaceCreateFlagBitsEXT>; using MetalSurfaceCreateFlagsEXT = Flags<MetalSurfaceCreateFlagBitsEXT>;
#endif /*VK_USE_PLATFORM_METAL_EXT*/ #endif /*VK_USE_PLATFORM_METAL_EXT*/
//=== VK_AMD_shader_core_properties2 === //=== VK_AMD_shader_core_properties2 ===
@ -8497,7 +8477,6 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( VideoEncodeRateControlModeFlagsKHR( bits ) ); return ~( VideoEncodeRateControlModeFlagsKHR( bits ) );
} }
#endif /*VK_ENABLE_BETA_EXTENSIONS*/ #endif /*VK_ENABLE_BETA_EXTENSIONS*/
//=== VK_NV_device_diagnostics_config === //=== VK_NV_device_diagnostics_config ===
@ -8576,7 +8555,6 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( ExportMetalObjectTypeFlagsEXT( bits ) ); return ~( ExportMetalObjectTypeFlagsEXT( bits ) );
} }
#endif /*VK_USE_PLATFORM_METAL_EXT*/ #endif /*VK_USE_PLATFORM_METAL_EXT*/
//=== VK_EXT_graphics_pipeline_library === //=== VK_EXT_graphics_pipeline_library ===
@ -8710,7 +8688,6 @@ namespace VULKAN_HPP_NAMESPACE
//=== VK_EXT_directfb_surface === //=== VK_EXT_directfb_surface ===
using DirectFBSurfaceCreateFlagsEXT = Flags<DirectFBSurfaceCreateFlagBitsEXT>; using DirectFBSurfaceCreateFlagsEXT = Flags<DirectFBSurfaceCreateFlagBitsEXT>;
#endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/ #endif /*VK_USE_PLATFORM_DIRECTFB_EXT*/
//=== VK_EXT_device_address_binding_report === //=== VK_EXT_device_address_binding_report ===
@ -8789,14 +8766,12 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( ImageConstraintsInfoFlagsFUCHSIA( bits ) ); return ~( ImageConstraintsInfoFlagsFUCHSIA( bits ) );
} }
#endif /*VK_USE_PLATFORM_FUCHSIA*/ #endif /*VK_USE_PLATFORM_FUCHSIA*/
#if defined( VK_USE_PLATFORM_SCREEN_QNX ) #if defined( VK_USE_PLATFORM_SCREEN_QNX )
//=== VK_QNX_screen_surface === //=== VK_QNX_screen_surface ===
using ScreenSurfaceCreateFlagsQNX = Flags<ScreenSurfaceCreateFlagBitsQNX>; using ScreenSurfaceCreateFlagsQNX = Flags<ScreenSurfaceCreateFlagBitsQNX>;
#endif /*VK_USE_PLATFORM_SCREEN_QNX*/ #endif /*VK_USE_PLATFORM_SCREEN_QNX*/
//=== VK_EXT_opacity_micromap === //=== VK_EXT_opacity_micromap ===
@ -9007,6 +8982,5 @@ namespace VULKAN_HPP_NAMESPACE
{ {
return ~( OpticalFlowExecuteFlagsNV( bits ) ); return ~( OpticalFlowExecuteFlagsNV( bits ) );
} }
} // namespace VULKAN_HPP_NAMESPACE } // namespace VULKAN_HPP_NAMESPACE
#endif #endif