change calls to std::find, std::find_if, and std::find_if_not to functionally identical calls to std::any_of, std::all_of, and std::none_of, when appropriate (#1621)

This commit is contained in:
Andreas Süßenbach 2023-07-13 11:26:01 +02:00 committed by GitHub
parent 069c3b875e
commit 207031caa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 270 additions and 283 deletions

View File

@ -109,10 +109,9 @@ bool checkLayers( std::vector<char const *> const & layers, std::vector<vk::Laye
layers.end(), layers.end(),
[&properties]( char const * name ) [&properties]( char const * name )
{ {
return std::find_if( properties.begin(), return std::any_of( properties.begin(),
properties.end(), properties.end(),
[&name]( vk::LayerProperties const & property ) [&name]( vk::LayerProperties const & property ) { return strcmp( property.layerName, name ) == 0; } );
{ return strcmp( property.layerName, name ) == 0; } ) != properties.end();
} ); } );
} }

View File

@ -70,6 +70,7 @@ struct GeometryInstanceData
uint32_t flags : 8; // Instance flags, such as culling uint32_t flags : 8; // Instance flags, such as culling
uint64_t accelerationStructureHandle; // Opaque handle of the bottom-level acceleration structure uint64_t accelerationStructureHandle; // Opaque handle of the bottom-level acceleration structure
}; };
static_assert( sizeof( GeometryInstanceData ) == 64, "GeometryInstanceData structure compiles to incorrect size" ); static_assert( sizeof( GeometryInstanceData ) == 64, "GeometryInstanceData structure compiles to incorrect size" );
struct AccelerationStructureData struct AccelerationStructureData
@ -198,6 +199,7 @@ struct Material
glm::vec3 diffuse = glm::vec3( 0.7f, 0.7f, 0.7f ); glm::vec3 diffuse = glm::vec3( 0.7f, 0.7f, 0.7f );
int textureID = -1; int textureID = -1;
}; };
const size_t MaterialStride = ( ( sizeof( Material ) + 15 ) / 16 ) * 16; const size_t MaterialStride = ( ( sizeof( Material ) + 15 ) / 16 ) * 16;
struct Vertex struct Vertex
@ -209,6 +211,7 @@ struct Vertex
glm::vec2 texCoord; glm::vec2 texCoord;
int matID; int matID;
}; };
const size_t VertexStride = ( ( sizeof( Vertex ) + 15 ) / 16 ) * 16; const size_t VertexStride = ( ( sizeof( Vertex ) + 15 ) / 16 ) * 16;
static const std::vector<Vertex> cubeData = { static const std::vector<Vertex> cubeData = {
@ -695,11 +698,9 @@ int main( int /*argc*/, char ** /*argv*/ )
for ( auto & pd : physicalDevices ) for ( auto & pd : physicalDevices )
{ {
std::vector<vk::ExtensionProperties> ep = pd.enumerateDeviceExtensionProperties(); std::vector<vk::ExtensionProperties> ep = pd.enumerateDeviceExtensionProperties();
if ( std::find_if( ep.cbegin(), if ( std::any_of( ep.cbegin(),
ep.cend(), ep.cend(),
[]( vk::ExtensionProperties const & prop ) []( vk::ExtensionProperties const & prop ) { return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) )
{ return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) !=
ep.cend() )
{ {
physicalDevice = pd; physicalDevice = pd;
break; break;
@ -733,11 +734,11 @@ int main( int /*argc*/, char ** /*argv*/ )
auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>(); auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>();
vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice,
graphicsAndPresentQueueFamilyIndex.first, graphicsAndPresentQueueFamilyIndex.first,
{ VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME,
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
VK_KHR_MAINTENANCE_3_EXTENSION_NAME, VK_KHR_MAINTENANCE_3_EXTENSION_NAME,
VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_NV_RAY_TRACING_EXTENSION_NAME }, VK_NV_RAY_TRACING_EXTENSION_NAME },
&supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features, &supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() ); &supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );

View File

@ -50,12 +50,12 @@ int main( int /*argc*/, char ** /*argv*/ )
{ {
vk::raii::Context context; vk::raii::Context context;
std::vector<vk::ExtensionProperties> instanceExtensionProperties = context.enumerateInstanceExtensionProperties(); std::vector<vk::ExtensionProperties> instanceExtensionProperties = context.enumerateInstanceExtensionProperties();
bool supportsGetSurfaceCapabilities2 = ( std::find_if( instanceExtensionProperties.begin(),
instanceExtensionProperties.end(), bool supportsGetSurfaceCapabilities2 =
[]( vk::ExtensionProperties const & ep ) { std::any_of( instanceExtensionProperties.begin(),
return strcmp( ep.extensionName, VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME ) == 0; instanceExtensionProperties.end(),
} ) != instanceExtensionProperties.end() ); []( vk::ExtensionProperties const & ep ) { return strcmp( ep.extensionName, VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME ) == 0; } );
std::vector<std::string> extensions = vk::su::getInstanceExtensions(); std::vector<std::string> extensions = vk::su::getInstanceExtensions();
if ( supportsGetSurfaceCapabilities2 ) if ( supportsGetSurfaceCapabilities2 )

View File

@ -103,7 +103,7 @@ std::vector<std::string>::iterator VideoHppGenerator::addImplicitlyRequiredTypes
( *typeIt->second.requiredBy.begin() == extensionData.depends ) ); ( *typeIt->second.requiredBy.begin() == extensionData.depends ) );
if ( typeIt->second.requiredBy.empty() && ( std::find( extensionData.requireData.types.begin(), reqIt, typeIt->first ) == reqIt ) ) if ( typeIt->second.requiredBy.empty() && ( std::find( extensionData.requireData.types.begin(), reqIt, typeIt->first ) == reqIt ) )
{ {
assert( std::find( reqIt, extensionData.requireData.types.end(), typeIt->first ) == extensionData.requireData.types.end() ); assert( std::none_of( reqIt, extensionData.requireData.types.end(), [&typeIt]( std::string const & type ) { return type == typeIt->first; } ) );
typeIt->second.requiredBy.insert( extensionData.name ); typeIt->second.requiredBy.insert( extensionData.name );
reqIt = std::next( extensionData.requireData.types.insert( reqIt, typeIt->first ) ); reqIt = std::next( extensionData.requireData.types.insert( reqIt, typeIt->first ) );
} }
@ -368,7 +368,7 @@ std::string VideoHppGenerator::generateStructs() const
${structs} ${structs}
)"; )";
std::string structs; std::string structs;
for ( auto const & extension : m_extensions ) for ( auto const & extension : m_extensions )
{ {
structs += generateStructs( extension.requireData, extension.name ); structs += generateStructs( extension.requireData, extension.name );
@ -396,7 +396,7 @@ std::string VideoHppGenerator::generateStructs( RequireData const & requireData,
bool VideoHppGenerator::isExtension( std::string const & name ) const bool VideoHppGenerator::isExtension( std::string const & name ) const
{ {
return std::find_if( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } ) != m_extensions.end(); return std::any_of( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } );
} }
void VideoHppGenerator::readEnums( tinyxml2::XMLElement const * element ) void VideoHppGenerator::readEnums( tinyxml2::XMLElement const * element )
@ -459,9 +459,7 @@ void VideoHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, std
std::string prefix = toUpperCase( enumIt->first ) + "_"; std::string prefix = toUpperCase( enumIt->first ) + "_";
checkForError( name.starts_with( prefix ), line, "encountered enum value <" + name + "> that does not begin with expected prefix <" + prefix + ">" ); checkForError( name.starts_with( prefix ), line, "encountered enum value <" + name + "> that does not begin with expected prefix <" + prefix + ">" );
checkForError( std::find_if( enumIt->second.values.begin(), checkForError( std::none_of( enumIt->second.values.begin(), enumIt->second.values.end(), [&name]( EnumValueData const & evd ) { return evd.name == name; } ),
enumIt->second.values.end(),
[&name]( EnumValueData const & evd ) { return evd.name == name; } ) == enumIt->second.values.end(),
line, line,
"enum value <" + name + "> already part of enum <" + enumIt->first + ">" ); "enum value <" + name + "> already part of enum <" + enumIt->first + ">" );
enumIt->second.values.push_back( { name, value, line } ); enumIt->second.values.push_back( { name, value, line } );
@ -670,7 +668,7 @@ void VideoHppGenerator::readStructMember( tinyxml2::XMLElement const * element,
} }
assert( !name.empty() ); assert( !name.empty() );
checkForError( std::find_if( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ) == members.end(), checkForError( std::none_of( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ),
line, line,
"struct member name <" + name + "> already used" ); "struct member name <" + name + "> already used" );
memberData.name = name; memberData.name = name;
@ -896,12 +894,13 @@ void VideoHppGenerator::sortStructs()
ext.requireData.types.erase( it ); ext.requireData.types.erase( it );
reqIt = std::next( ext.requireData.types.insert( reqIt, member.type.type ) ); reqIt = std::next( ext.requireData.types.insert( reqIt, member.type.type ) );
} }
#if !defined(NDEBUG) #if !defined( NDEBUG )
else else
{ {
auto depIt = std::find_if( m_extensions.begin(), m_extensions.end(), [&ext]( ExtensionData const & ed ) { return ed.name == ext.depends; } ); auto depIt = std::find_if( m_extensions.begin(), m_extensions.end(), [&ext]( ExtensionData const & ed ) { return ed.name == ext.depends; } );
assert( ( depIt != m_extensions.end() ) && assert( ( depIt != m_extensions.end() ) && std::any_of( depIt->requireData.types.begin(),
( std::find( depIt->requireData.types.begin(), depIt->requireData.types.end(), member.type.type ) != depIt->requireData.types.end() ) ); depIt->requireData.types.end(),
[&member]( std::string const & type ) { return type == member.type.type; } ) );
} }
#endif #endif
} }
@ -960,9 +959,9 @@ int main( int argc, char ** argv )
generator.generateHppFile(); generator.generateHppFile();
# if !defined( CLANG_FORMAT_EXECUTABLE ) #if !defined( CLANG_FORMAT_EXECUTABLE )
std::cout << "VideoHppGenerator: could not find clang-format. The generated files will not be formatted accordingly.\n"; std::cout << "VideoHppGenerator: could not find clang-format. The generated files will not be formatted accordingly.\n";
# endif #endif
} }
catch ( std::exception const & e ) catch ( std::exception const & e )
{ {

View File

@ -818,8 +818,7 @@ void VulkanHppGenerator::addMissingFlagBits( std::vector<RequireData> & requireD
std::string flagBits = bitmaskIt->first.substr( 0, pos + 4 ) + "Bit" + bitmaskIt->first.substr( pos + 4 ); std::string flagBits = bitmaskIt->first.substr( 0, pos + 4 ) + "Bit" + bitmaskIt->first.substr( pos + 4 );
// as the bitmask's requirement is still empty, this flagBits should not be listed in the require list! // as the bitmask's requirement is still empty, this flagBits should not be listed in the require list!
assert( std::find_if( require.types.begin(), require.types.end(), [&flagBits]( std::string const & type ) { return ( type == flagBits ); } ) == assert( std::none_of( require.types.begin(), require.types.end(), [&flagBits]( std::string const & type ) { return ( type == flagBits ); } ) );
require.types.end() );
bitmaskIt->second.require = flagBits; bitmaskIt->second.require = flagBits;
@ -866,14 +865,14 @@ std::string VulkanHppGenerator::addTitleAndProtection( std::string const & title
bool VulkanHppGenerator::allVectorSizesSupported( std::vector<ParamData> const & params, std::map<size_t, VectorParamData> const & vectorParams ) const bool VulkanHppGenerator::allVectorSizesSupported( std::vector<ParamData> const & params, std::map<size_t, VectorParamData> const & vectorParams ) const
{ {
// check if all vector sizes are by value and their type is one of "uint32_t", "VkDeviceSize", or "VkSampleCountFlagBits" // check if all vector sizes are by value and their type is one of "uint32_t", "VkDeviceSize", or "VkSampleCountFlagBits"
return std::find_if_not( vectorParams.begin(), return std::all_of( vectorParams.begin(),
vectorParams.end(), vectorParams.end(),
[&params]( auto const & vpi ) [&params]( auto const & vpi )
{ {
return params[vpi.second.lenParam].type.isValue() && return params[vpi.second.lenParam].type.isValue() &&
( ( params[vpi.second.lenParam].type.type == "uint32_t" ) || ( params[vpi.second.lenParam].type.type == "VkDeviceSize" ) || ( ( params[vpi.second.lenParam].type.type == "uint32_t" ) || ( params[vpi.second.lenParam].type.type == "VkDeviceSize" ) ||
( params[vpi.second.lenParam].type.type == "VkSampleCountFlagBits" ) ); ( params[vpi.second.lenParam].type.type == "VkSampleCountFlagBits" ) );
} ) == vectorParams.end(); } );
} }
void VulkanHppGenerator::appendDispatchLoaderDynamicCommands( std::vector<RequireData> const & requireData, void VulkanHppGenerator::appendDispatchLoaderDynamicCommands( std::vector<RequireData> const & requireData,
@ -1121,14 +1120,12 @@ void VulkanHppGenerator::checkEnumCorrectness() const
// check that the alias names are known enum values // check that the alias names are known enum values
for ( auto const & value : e.second.values ) for ( auto const & value : e.second.values )
{ {
checkForError( value.alias.empty() || checkForError(
( std::find_if( e.second.values.begin(), e.second.values.end(), [&value]( auto const & evd ) { return evd.name == value.alias; } ) != value.alias.empty() ||
e.second.values.end() ) || std::any_of( e.second.values.begin(), e.second.values.end(), [&value]( auto const & evd ) { return evd.name == value.alias; } ) ||
( std::find_if( e.second.unsupportedValues.begin(), std::any_of( e.second.unsupportedValues.begin(), e.second.unsupportedValues.end(), [&value]( auto const & evd ) { return evd.name == value.alias; } ),
e.second.unsupportedValues.end(), value.xmlLine,
[&value]( auto const & evd ) { return evd.name == value.alias; } ) != e.second.unsupportedValues.end() ), "enum <" + value.name + "> uses unknown alias <" + value.alias + ">" );
value.xmlLine,
"enum <" + value.name + "> uses unknown alias <" + value.alias + ">" );
} }
} }
@ -1261,7 +1258,7 @@ bool VulkanHppGenerator::checkEquivalentSingularConstructor( std::vector<std::ma
} }
return true; return true;
}; };
return ( std::find_if( constructorIts.begin(), constructorIts.end(), isEquivalentSingularConstructor ) != constructorIts.end() ); return ( std::any_of( constructorIts.begin(), constructorIts.end(), isEquivalentSingularConstructor ) );
} }
void VulkanHppGenerator::checkExtensionCorrectness() const void VulkanHppGenerator::checkExtensionCorrectness() const
@ -1353,10 +1350,9 @@ void VulkanHppGenerator::checkHandleCorrectness() const
assert( !handle.second.objTypeEnum.empty() ); assert( !handle.second.objTypeEnum.empty() );
// only check with used handles! // only check with used handles!
checkForError( !isTypeUsed( handle.first ) || std::find_if( objectTypeIt->second.values.begin(), checkForError( !isTypeUsed( handle.first ) || std::any_of( objectTypeIt->second.values.begin(),
objectTypeIt->second.values.end(), objectTypeIt->second.values.end(),
[&handle]( EnumValueData const & evd ) [&handle]( EnumValueData const & evd ) { return evd.name == handle.second.objTypeEnum; } ),
{ return evd.name == handle.second.objTypeEnum; } ) != objectTypeIt->second.values.end(),
handle.second.xmlLine, handle.second.xmlLine,
"handle <" + handle.first + "> specifies unknown \"objtypeenum\" <" + handle.second.objTypeEnum + ">" ); "handle <" + handle.first + "> specifies unknown \"objtypeenum\" <" + handle.second.objTypeEnum + ">" );
} }
@ -1368,10 +1364,10 @@ void VulkanHppGenerator::checkHandleCorrectness() const
if ( objectTypeValue.name != "VK_OBJECT_TYPE_UNKNOWN" ) if ( objectTypeValue.name != "VK_OBJECT_TYPE_UNKNOWN" )
{ {
// check for non-alias objectTypes only // check for non-alias objectTypes only
checkForError( !objectTypeValue.alias.empty() || ( std::find_if( m_handles.begin(), checkForError( !objectTypeValue.alias.empty() || std::any_of( m_handles.begin(),
m_handles.end(), m_handles.end(),
[&objectTypeValue]( std::pair<std::string, HandleData> const & hd ) [&objectTypeValue]( std::pair<std::string, HandleData> const & hd )
{ return hd.second.objTypeEnum == objectTypeValue.name; } ) != m_handles.end() ), { return hd.second.objTypeEnum == objectTypeValue.name; } ),
objectTypeValue.xmlLine, objectTypeValue.xmlLine,
"VkObjectType value <" + objectTypeValue.name + "> not specified as \"objtypeenum\" for any handle" ); "VkObjectType value <" + objectTypeValue.name + "> not specified as \"objtypeenum\" for any handle" );
} }
@ -1467,16 +1463,15 @@ void VulkanHppGenerator::checkStructMemberCorrectness( std::string const &
assert( !unionMember.selection.empty() ); assert( !unionMember.selection.empty() );
for ( auto const & selection : unionMember.selection ) for ( auto const & selection : unionMember.selection )
{ {
checkForError( checkForError( std::any_of( selectorEnumIt->second.values.begin(),
( std::find_if( selectorEnumIt->second.values.begin(), selectorEnumIt->second.values.end(),
selectorEnumIt->second.values.end(), [&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) ||
[&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) != selectorEnumIt->second.values.end() ) || std::any_of( selectorEnumIt->second.unsupportedValues.begin(),
( std::find_if( selectorEnumIt->second.unsupportedValues.begin(), selectorEnumIt->second.unsupportedValues.end(),
selectorEnumIt->second.unsupportedValues.end(), [&selection]( EnumValueData const & evd ) { return evd.name == selection; } ),
[&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) != selectorEnumIt->second.unsupportedValues.end() ), unionMember.xmlLine,
unionMember.xmlLine, "union member <" + unionMember.name + "> uses selection <" + selection + "> that is not part of the selector type <" +
"union member <" + unionMember.name + "> uses selection <" + selection + "> that is not part of the selector type <" + selectorIt->type.type + selectorIt->type.type + ">" );
">" );
} }
} }
} }
@ -1501,12 +1496,11 @@ void VulkanHppGenerator::checkStructMemberCorrectness( std::string const &
// check that the value exists in the specified enum (if the struct is used at all) // check that the value exists in the specified enum (if the struct is used at all)
if ( structUsed ) if ( structUsed )
{ {
checkForError( std::find_if( enumIt->second.values.begin(), checkForError(
enumIt->second.values.end(), std::any_of( enumIt->second.values.begin(), enumIt->second.values.end(), [&member]( auto const & evd ) { return member.value == evd.name; } ),
[&member]( auto const & evd ) { return member.value == evd.name; } ) != enumIt->second.values.end(), member.xmlLine,
member.xmlLine, "value <" + member.value + "> for member <" + member.name + "> in structure <" + structureName + "> of enum type <" + member.type.type +
"value <" + member.value + "> for member <" + member.name + "> in structure <" + structureName + "> of enum type <" + "> not listed" );
member.type.type + "> not listed" );
// special handling for sType: no value should appear more than once // special handling for sType: no value should appear more than once
if ( member.name == "sType" ) if ( member.name == "sType" )
{ {
@ -1687,8 +1681,9 @@ std::vector<std::string> VulkanHppGenerator::determineDataTypes( std::vector<Vul
if ( templatedParams.find( rp ) != templatedParams.end() ) if ( templatedParams.find( rp ) != templatedParams.end() )
{ {
auto vectorParamIt = vectorParams.find( rp ); auto vectorParamIt = vectorParams.find( rp );
if ( ( vectorParamIt != vectorParams.end() ) && ( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->first ) != returnParams.end() ) && if ( ( vectorParamIt != vectorParams.end() ) &&
( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) != returnParams.end() ) ) std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) &&
std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) )
{ {
dataTypes.push_back( "uint8_t" ); dataTypes.push_back( "uint8_t" );
} }
@ -1719,13 +1714,13 @@ size_t VulkanHppGenerator::determineDefaultStartIndex( std::vector<ParamData> co
bool VulkanHppGenerator::determineEnumeration( std::map<size_t, VectorParamData> const & vectorParams, std::vector<size_t> const & returnParams ) const bool VulkanHppGenerator::determineEnumeration( std::map<size_t, VectorParamData> const & vectorParams, std::vector<size_t> const & returnParams ) const
{ {
// a command is considered to be enumerating some data, if for at least one vectorParam both, the data and the counter, are returnParams // a command is considered to be enumerating some data, if for at least one vectorParam both, the data and the counter, are returnParams
return std::find_if( vectorParams.begin(), return std::any_of( vectorParams.begin(),
vectorParams.end(), vectorParams.end(),
[&returnParams]( auto const & vp ) [&returnParams]( auto const & vp )
{ {
return std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() && return std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.first; } ) &&
std::find( returnParams.begin(), returnParams.end(), vp.second.lenParam ) != returnParams.end(); std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.second.lenParam; } );
} ) != vectorParams.end(); } );
} }
size_t VulkanHppGenerator::determineInitialSkipCount( std::string const & command ) const size_t VulkanHppGenerator::determineInitialSkipCount( std::string const & command ) const
@ -1778,11 +1773,10 @@ std::vector<std::map<std::string, VulkanHppGenerator::CommandData>::const_iterat
std::vector<std::map<std::string, CommandData>::const_iterator> constructorIts; std::vector<std::map<std::string, CommandData>::const_iterator> constructorIts;
auto isConstructorCandidate = [this, &handleType]( std::pair<std::string, CommandData> const & cd ) auto isConstructorCandidate = [this, &handleType]( std::pair<std::string, CommandData> const & cd )
{ {
return isSupported( cd.second.requiredBy ) && ( std::find_if( cd.second.params.begin(), return isSupported( cd.second.requiredBy ) &&
cd.second.params.end(), std::any_of( cd.second.params.begin(),
[&handleType]( ParamData const & pd ) { cd.second.params.end(),
return ( pd.type.type == handleType ) && pd.type.isNonConstPointer(); [&handleType]( ParamData const & pd ) { return ( pd.type.type == handleType ) && pd.type.isNonConstPointer(); } );
} ) != cd.second.params.end() );
}; };
for ( auto commandIt = m_commands.begin(); commandIt != m_commands.end(); ) for ( auto commandIt = m_commands.begin(); commandIt != m_commands.end(); )
{ {
@ -1819,13 +1813,12 @@ std::vector<std::map<std::string, VulkanHppGenerator::CommandData>::const_iterat
}; };
return ( destructorParam.name == desctructorHandleParamIt->lenExpression ) || return ( destructorParam.name == desctructorHandleParamIt->lenExpression ) ||
( std::find_if( commandIt->second.params.begin(), commandIt->second.params.end(), isDestructorParamType ) != commandIt->second.params.end() ); std::any_of( commandIt->second.params.begin(), commandIt->second.params.end(), isDestructorParamType );
}; };
// the constructor candidate is valid, if none of the (relevant) destructor parameters is missing in the // the constructor candidate is valid, if none of the (relevant) destructor parameters is missing in the
// constructor candidate params // constructor candidate params
valid = ( std::find_if_not( destructorIt->second.params.begin(), destructorIt->second.params.end(), isConstructorCandidateParam ) == valid = std::all_of( destructorIt->second.params.begin(), destructorIt->second.params.end(), isConstructorCandidateParam );
destructorIt->second.params.end() );
} }
if ( valid ) if ( valid )
{ {
@ -1905,7 +1898,7 @@ std::set<size_t> VulkanHppGenerator::determineSkippedParams( std::vector<ParamDa
for ( auto const & vpi : vectorParams ) for ( auto const & vpi : vectorParams )
{ {
assert( !params[vpi.first].lenExpression.empty() ); assert( !params[vpi.first].lenExpression.empty() );
if ( ( ( std::find_if( returnParams.begin(), returnParams.end(), [&vpi]( size_t rpi ) { return vpi.first == rpi; } ) == returnParams.end() ) && if ( ( std::none_of( returnParams.begin(), returnParams.end(), [&vpi]( size_t rpi ) { return vpi.first == rpi; } ) &&
isParam( params[vpi.first].lenExpression, params ) ) || isParam( params[vpi.first].lenExpression, params ) ) ||
( singular && params[vpi.second.lenParam].type.isValue() ) ) ( singular && params[vpi.second.lenParam].type.isValue() ) )
{ {
@ -1942,8 +1935,7 @@ std::string VulkanHppGenerator::determineSubStruct( std::pair<std::string, Struc
return false; return false;
}; };
return ( sd.second.members.size() < structure.second.members.size() ) && return ( sd.second.members.size() < structure.second.members.size() ) && std::all_of( sd.second.members.begin(), sd.second.members.end(), isMember );
( std::find_if_not( sd.second.members.begin(), sd.second.members.end(), isMember ) == sd.second.members.end() );
}; };
// look for a struct in m_structs that starts identically to structure // look for a struct in m_structs that starts identically to structure
@ -1967,7 +1959,7 @@ std::map<size_t, VulkanHppGenerator::VectorParamData> VulkanHppGenerator::determ
if ( params[i].lenParams.empty() ) if ( params[i].lenParams.empty() )
{ {
std::string const & lenExpression = params[i].lenExpression; std::string const & lenExpression = params[i].lenExpression;
assert( std::find_if( params.begin(), params.end(), [&lenExpression]( auto const & pd ) { return ( lenExpression == pd.name ); } ) == params.end() ); assert( std::none_of( params.begin(), params.end(), [&lenExpression]( auto const & pd ) { return ( lenExpression == pd.name ); } ) );
auto lenIt = auto lenIt =
std::find_if( params.begin(), params.end(), [this, &lenExpression]( auto const & pd ) { return isLenByStructMember( lenExpression, pd ); } ); std::find_if( params.begin(), params.end(), [this, &lenExpression]( auto const & pd ) { return isLenByStructMember( lenExpression, pd ); } );
assert( lenIt != params.end() ); assert( lenIt != params.end() );
@ -2024,10 +2016,9 @@ void VulkanHppGenerator::distributeSecondLevelCommands( std::set<std::string> co
assert( !handleIt->second.constructorIts.empty() ); assert( !handleIt->second.constructorIts.empty() );
if ( ( *handleIt->second.constructorIts.begin() )->second.handle == handle.first ) if ( ( *handleIt->second.constructorIts.begin() )->second.handle == handle.first )
{ {
assert( std::find_if( handleIt->second.constructorIts.begin(), assert( std::none_of( handleIt->second.constructorIts.begin(),
handleIt->second.constructorIts.end(), handleIt->second.constructorIts.end(),
[&handle]( auto const & constructorIt ) [&handle]( auto const & constructorIt ) { return constructorIt->second.handle != handle.first; } ) );
{ return constructorIt->second.handle != handle.first; } ) == handleIt->second.constructorIts.end() );
handleIt->second.secondLevelCommands.insert( *command ); handleIt->second.secondLevelCommands.insert( *command );
command = handle.second.commands.erase( command ); command = handle.second.commands.erase( command );
foundCommand = true; foundCommand = true;
@ -2073,7 +2064,7 @@ std::map<std::string, VulkanHppGenerator::AliasData>::const_iterator VulkanHppGe
{ {
auto lambda = [&name]( std::pair<std::string, AliasData> const & ad ) { return ad.second.name == name; }; auto lambda = [&name]( std::pair<std::string, AliasData> const & ad ) { return ad.second.name == name; };
auto it = std::find_if( aliases.begin(), aliases.end(), lambda ); auto it = std::find_if( aliases.begin(), aliases.end(), lambda );
assert( ( it == aliases.end() ) || ( std::find_if( std::next( it ), aliases.end(), lambda ) == aliases.end() ) ); assert( ( it == aliases.end() ) || std::none_of( std::next( it ), aliases.end(), lambda ) );
return it; return it;
} }
@ -2338,8 +2329,8 @@ std::string VulkanHppGenerator::generateArgumentListEnhanced( std::vector<ParamD
{ {
auto vectorParamIt = vectorParams.find( sp ); auto vectorParamIt = vectorParams.find( sp );
if ( ( vectorParamIt != vectorParams.end() ) && if ( ( vectorParamIt != vectorParams.end() ) &&
( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->first ) != returnParams.end() ) && std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) &&
( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) != returnParams.end() ) ) std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) )
{ {
type = "Uint8_t"; type = "Uint8_t";
} }
@ -2403,8 +2394,9 @@ std::string VulkanHppGenerator::generateArgumentTemplates( std::vector<ParamData
{ {
assert( params[t].name.starts_with( "p" ) ); assert( params[t].name.starts_with( "p" ) );
auto vectorParamIt = vectorParams.find( t ); auto vectorParamIt = vectorParams.find( t );
if ( ( vectorParamIt == vectorParams.end() ) || ( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->first ) == returnParams.end() ) || if ( ( vectorParamIt == vectorParams.end() ) ||
( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) == returnParams.end() ) ) std::none_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) ||
std::none_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) )
{ {
assert( chainedReturnParams.empty() ); assert( chainedReturnParams.empty() );
// only templated parameters that are not part of an enumeration are really templated // only templated parameters that are not part of an enumeration are really templated
@ -2925,8 +2917,7 @@ std::string VulkanHppGenerator::generateCallArgumentEnhancedValue( std::vector<P
argument = "static_cast<" + param.type.compose( "" ) + ">( " + param.name + " )"; argument = "static_cast<" + param.type.compose( "" ) + ">( " + param.name + " )";
} }
// check if this param is used as the stride of an other param // check if this param is used as the stride of an other param
assert( std::find_if( params.begin(), params.end(), [paramIndex]( ParamData const & pd ) { return pd.strideParam.second == paramIndex; } ) == assert( std::none_of( params.begin(), params.end(), [paramIndex]( ParamData const & pd ) { return pd.strideParam.second == paramIndex; } ) );
params.end() );
} }
else else
{ {
@ -3000,17 +2991,14 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
std::string dispatcher = raii ? "getDispatcher()->" : "d."; std::string dispatcher = raii ? "getDispatcher()->" : "d.";
// if at least one returnParam is a size value of a vector param (and no singular params), we need two calls // if at least one returnParam is a size value of a vector param (and no singular params), we need two calls
if ( singularParams.empty() && if ( singularParams.empty() &&
( std::find_if( returnParams.begin(), std::any_of( returnParams.begin(),
returnParams.end(), returnParams.end(),
[&vectorParams]( size_t rp ) [&vectorParams]( size_t rp )
{ { return std::any_of( vectorParams.begin(), vectorParams.end(), [rp]( auto const & vp ) { return vp.second.lenParam == rp; } ); } ) )
return ( std::find_if( vectorParams.begin(), vectorParams.end(), [rp]( auto const & vp ) { return vp.second.lenParam == rp; } ) !=
vectorParams.end() );
} ) != returnParams.end() ) )
{ {
auto vectorParamIt = vectorParams.begin(); auto vectorParamIt = vectorParams.begin();
assert( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->first ) != returnParams.end() ); assert( std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->first; } ) );
assert( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) != returnParams.end() ); assert( std::any_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) );
std::string firstCallArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, true, {}, templatedParams, raii ); std::string firstCallArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, true, {}, templatedParams, raii );
std::string secondCallArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, raii ); std::string secondCallArguments = generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, raii );
@ -3079,8 +3067,8 @@ std::string VulkanHppGenerator::generateCallSequence( std::string const &
std::string resizes; std::string resizes;
for ( auto const & vp : vectorParams ) for ( auto const & vp : vectorParams )
{ {
assert( ( std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() ) && assert( std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.first; } ) &&
( std::find( returnParams.begin(), returnParams.end(), vp.second.lenParam ) != returnParams.end() ) ); std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.second.lenParam; } ) );
resizes += startLowerCase( stripPrefix( commandData.params[vp.first].name, "p" ) ) + ".resize( " + resizes += startLowerCase( stripPrefix( commandData.params[vp.first].name, "p" ) ) + ".resize( " +
startLowerCase( stripPrefix( commandData.params[vp.second.lenParam].name, "p" ) ) + " );\n"; startLowerCase( stripPrefix( commandData.params[vp.second.lenParam].name, "p" ) ) + " );\n";
} }
@ -5743,8 +5731,8 @@ std::string VulkanHppGenerator::generateDataPreparation( CommandData const &
std::string resizes; std::string resizes;
for ( auto const & vp : vectorParams ) for ( auto const & vp : vectorParams )
{ {
assert( ( std::find( returnParams.begin(), returnParams.end(), vp.first ) != returnParams.end() ) && assert( std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.first; } ) &&
( std::find( returnParams.begin(), returnParams.end(), vp.second.lenParam ) != returnParams.end() ) ); std::any_of( returnParams.begin(), returnParams.end(), [&vp]( size_t rp ) { return rp == vp.second.lenParam; } ) );
resizes += startLowerCase( stripPrefix( commandData.params[vp.first].name, "p" ) ) + ".resize( " + resizes += startLowerCase( stripPrefix( commandData.params[vp.first].name, "p" ) ) + ".resize( " +
startLowerCase( stripPrefix( commandData.params[vp.second.lenParam].name, "p" ) ) + " );\n"; startLowerCase( stripPrefix( commandData.params[vp.second.lenParam].name, "p" ) ) + " );\n";
} }
@ -5830,7 +5818,7 @@ std::string VulkanHppGenerator::generateDataSizeChecks( CommandData const &
{ {
auto vectorParamIt = vectorParams.find( returnParams[i] ); auto vectorParamIt = vectorParams.find( returnParams[i] );
if ( ( vectorParamIt != vectorParams.end() ) && ( templatedParams.find( returnParams[i] ) != templatedParams.end() ) && if ( ( vectorParamIt != vectorParams.end() ) && ( templatedParams.find( returnParams[i] ) != templatedParams.end() ) &&
( std::find( returnParams.begin(), returnParams.end(), vectorParamIt->second.lenParam ) == returnParams.end() ) ) std::none_of( returnParams.begin(), returnParams.end(), [&vectorParamIt]( size_t rp ) { return rp == vectorParamIt->second.lenParam; } ) )
{ {
dataSizeChecks += replaceWithMap( dataSizeCheckTemplate, dataSizeChecks += replaceWithMap( dataSizeCheckTemplate,
{ { "dataSize", commandData.params[vectorParamIt->second.lenParam].name }, { "dataType", returnParamTypes[i] } } ); { { "dataSize", commandData.params[vectorParamIt->second.lenParam].name }, { "dataType", returnParamTypes[i] } } );
@ -7476,7 +7464,7 @@ ${indexTypeTraits}
assert( valueName.starts_with( "eUint" ) ); assert( valueName.starts_with( "eUint" ) );
auto beginDigit = valueName.begin() + strlen( "eUint" ); auto beginDigit = valueName.begin() + strlen( "eUint" );
assert( isdigit( *beginDigit ) ); assert( isdigit( *beginDigit ) );
auto endDigit = std::find_if_not( beginDigit, valueName.end(), []( std::string::value_type c ) { return isdigit( c ); } ); auto endDigit = std::find_if( beginDigit, valueName.end(), []( std::string::value_type c ) { return !isdigit( c ); } );
cppType = "uint" + valueName.substr( strlen( "eUint" ), endDigit - beginDigit ) + "_t"; cppType = "uint" + valueName.substr( strlen( "eUint" ), endDigit - beginDigit ) + "_t";
} }
@ -7585,9 +7573,8 @@ std::string VulkanHppGenerator::generateNoExcept( std::vector<std::string> const
// noexcept is only possible with no error codes, and the return param (if any) is not a vector param (unless it's the singular version) // noexcept is only possible with no error codes, and the return param (if any) is not a vector param (unless it's the singular version)
return ( errorCodes.empty() && return ( errorCodes.empty() &&
( ( flavourFlags & CommandFlavourFlagBits::singular ) || returnParams.empty() || ( ( flavourFlags & CommandFlavourFlagBits::singular ) || returnParams.empty() ||
( std::find_if( returnParams.begin(), std::none_of(
returnParams.end(), returnParams.begin(), returnParams.end(), [&vectorParams]( size_t rp ) { return vectorParams.find( rp ) != vectorParams.end(); } ) ) )
[&vectorParams]( size_t rp ) { return vectorParams.find( rp ) != vectorParams.end(); } ) == returnParams.end() ) ) )
? ( vectorSizeCheck ? ( raii ? "" : " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" ) : " VULKAN_HPP_NOEXCEPT" ) ? ( vectorSizeCheck ? ( raii ? "" : " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" ) : " VULKAN_HPP_NOEXCEPT" )
: ""; : "";
} }
@ -8425,9 +8412,9 @@ std::string VulkanHppGenerator::generateRAIIHandleConstructorArguments( std::pai
#endif #endif
continue; continue;
} }
else if ( std::find_if( constructorIt->second.params.begin(), else if ( std::any_of( constructorIt->second.params.begin(),
constructorIt->second.params.end(), constructorIt->second.params.end(),
[&param]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) != constructorIt->second.params.end() ) [&param]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) )
{ {
// this is the len of an other parameter, which will be mapped to an ArrayProxy // this is the len of an other parameter, which will be mapped to an ArrayProxy
assert( param.type.isValue() && ( param.type.type == "uint32_t" ) ); assert( param.type.isValue() && ( param.type.type == "uint32_t" ) );
@ -8701,9 +8688,9 @@ std::string VulkanHppGenerator::generateRAIIHandleConstructorParamName( std::str
[&type]( ParamData const & destructorParam ) { return destructorParam.type.type == type; } ); [&type]( ParamData const & destructorParam ) { return destructorParam.type.type == type; } );
if ( destructorParamIt != destructorIt->second.params.end() ) if ( destructorParamIt != destructorIt->second.params.end() )
{ {
assert( std::find_if( std::next( destructorParamIt ), assert( std::none_of( std::next( destructorParamIt ),
destructorIt->second.params.end(), destructorIt->second.params.end(),
[&type]( ParamData const & destructorParam ) { return destructorParam.type.type == type; } ) == destructorIt->second.params.end() ); [&type]( ParamData const & destructorParam ) { return destructorParam.type.type == type; } ) );
if ( !destructorParamIt->type.isValue() ) if ( !destructorParamIt->type.isValue() )
{ {
return startLowerCase( stripPrefix( stripPluralS( destructorParamIt->name ), "p" ) ); return startLowerCase( stripPrefix( stripPluralS( destructorParamIt->name ), "p" ) );
@ -9215,19 +9202,17 @@ std::string VulkanHppGenerator::generateRAIIHandleDestructorCallArguments( std::
else else
{ {
assert( param.type.isConstPointer() ); assert( param.type.isConstPointer() );
assert( !param.lenExpression.empty() && assert( !param.lenExpression.empty() && std::any_of( destructorIt->second.params.begin(),
( std::find_if( destructorIt->second.params.begin(), destructorIt->second.params.end(),
destructorIt->second.params.end(), [&param]( ParamData const & pd ) { return pd.name == param.lenExpression; } ) );
[&param]( ParamData const & pd ) { return pd.name == param.lenExpression; } ) != destructorIt->second.params.end() ) );
arguments += "reinterpret_cast<" + param.type.type + " const *>( &" + argument + " )"; arguments += "reinterpret_cast<" + param.type.type + " const *>( &" + argument + " )";
} }
} }
else else
{ {
assert( ( param.type.type == "uint32_t" ) && param.type.isValue() && param.arraySizes.empty() && param.lenExpression.empty() && !param.optional ); assert( ( param.type.type == "uint32_t" ) && param.type.isValue() && param.arraySizes.empty() && param.lenExpression.empty() && !param.optional );
assert( std::find_if( destructorIt->second.params.begin(), assert( std::any_of(
destructorIt->second.params.end(), destructorIt->second.params.begin(), destructorIt->second.params.end(), [&param]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) );
[&param]( ParamData const & pd ) { return pd.lenExpression == param.name; } ) != destructorIt->second.params.end() );
arguments += "1"; arguments += "1";
} }
encounteredArgument = true; encounteredArgument = true;
@ -9276,10 +9261,9 @@ std::tuple<std::string, std::string, std::string, std::string, std::string, std:
memberName = handleName; memberName = handleName;
memberType = generateNamespacedType( handle.first ); memberType = generateNamespacedType( handle.first );
} }
else if ( std::find_if( handle.second.destructorIt->second.params.begin(), else if ( std::none_of( handle.second.destructorIt->second.params.begin(),
handle.second.destructorIt->second.params.end(), handle.second.destructorIt->second.params.end(),
[&destructorParam]( ParamData const & pd ) [&destructorParam]( ParamData const & pd ) { return pd.lenExpression == destructorParam.name; } ) )
{ return pd.lenExpression == destructorParam.name; } ) == handle.second.destructorIt->second.params.end() )
{ {
std::string name = destructorParam.name; std::string name = destructorParam.name;
if ( !destructorParam.type.isValue() ) if ( !destructorParam.type.isValue() )
@ -9446,15 +9430,13 @@ std::string VulkanHppGenerator::generateRAIIHandleSingularConstructorArguments(
for ( auto const & destructorParam : handle.second.destructorIt->second.params ) for ( auto const & destructorParam : handle.second.destructorIt->second.params )
{ {
if ( ( destructorParam.type.type != parentType ) && ( destructorParam.type.type != handle.first ) && if ( ( destructorParam.type.type != parentType ) && ( destructorParam.type.type != handle.first ) &&
( std::find_if( handle.second.destructorIt->second.params.begin(), std::none_of( handle.second.destructorIt->second.params.begin(),
handle.second.destructorIt->second.params.end(), handle.second.destructorIt->second.params.end(),
[&destructorParam]( ParamData const & pd ) [&destructorParam]( ParamData const & pd ) { return pd.lenExpression == destructorParam.name; } ) )
{ return pd.lenExpression == destructorParam.name; } ) == handle.second.destructorIt->second.params.end() ) )
{ {
if ( std::find_if( constructorIt->second.params.begin(), if ( std::any_of( constructorIt->second.params.begin(),
constructorIt->second.params.end(), constructorIt->second.params.end(),
[&destructorParam]( ParamData const & pd ) [&destructorParam]( ParamData const & pd ) { return pd.type.type == destructorParam.type.type; } ) )
{ return pd.type.type == destructorParam.type.type; } ) != constructorIt->second.params.end() )
{ {
if ( isHandleType( destructorParam.type.type ) ) if ( isHandleType( destructorParam.type.type ) )
{ {
@ -10370,8 +10352,7 @@ std::string VulkanHppGenerator::generateStructConstructors( std::pair<std::strin
std::string VulkanHppGenerator::generateStructConstructorsEnhanced( std::pair<std::string, StructureData> const & structData ) const std::string VulkanHppGenerator::generateStructConstructorsEnhanced( std::pair<std::string, StructureData> const & structData ) const
{ {
if ( std::find_if( structData.second.members.begin(), structData.second.members.end(), [this]( MemberData const & md ) { return hasLen( md ); } ) != if ( std::any_of( structData.second.members.begin(), structData.second.members.end(), [this]( MemberData const & md ) { return hasLen( md ); } ) )
structData.second.members.end() )
{ {
// map from len-members to all the array members using that len // map from len-members to all the array members using that len
std::map<std::vector<MemberData>::const_iterator, std::vector<std::vector<MemberData>::const_iterator>> lenIts; std::map<std::vector<MemberData>::const_iterator, std::vector<std::vector<MemberData>::const_iterator>> lenIts;
@ -11246,10 +11227,11 @@ std::string VulkanHppGenerator::generateTypenameCheck( std::vector<size_t> const
{ {
if ( vectorParams.find( returnParams[i] ) != vectorParams.end() ) if ( vectorParams.find( returnParams[i] ) != vectorParams.end() )
{ {
std::string elementType = ( ( flavourFlags & CommandFlavourFlagBits::chained ) && std::string elementType =
( std::find( chainedReturnParams.begin(), chainedReturnParams.end(), returnParams[i] ) != chainedReturnParams.end() ) ) ( ( flavourFlags & CommandFlavourFlagBits::chained ) &&
? "StructureChain" std::any_of( chainedReturnParams.begin(), chainedReturnParams.end(), [&returnParams, i]( size_t crp ) { return crp == returnParams[i]; } ) )
: stripPrefix( dataTypes[i], "VULKAN_HPP_NAMESPACE::" ); ? "StructureChain"
: stripPrefix( dataTypes[i], "VULKAN_HPP_NAMESPACE::" );
std::string extendedElementType = elementType; std::string extendedElementType = elementType;
if ( flavourFlags & CommandFlavourFlagBits::unique ) if ( flavourFlags & CommandFlavourFlagBits::unique )
{ {
@ -11304,9 +11286,7 @@ std::string VulkanHppGenerator::generateUnion( std::pair<std::string, StructureD
} }
bool multipleType = bool multipleType =
( std::find_if( std::next( memberIt ), std::any_of( std::next( memberIt ), structure.second.members.end(), [memberIt]( MemberData const & member ) { return member.type == memberIt->type; } );
structure.second.members.end(),
[memberIt]( MemberData const & member ) { return member.type == memberIt->type; } ) != structure.second.members.end() );
std::string memberType = ( memberIt->arraySizes.empty() ) std::string memberType = ( memberIt->arraySizes.empty() )
? memberIt->type.compose( "VULKAN_HPP_NAMESPACE" ) ? memberIt->type.compose( "VULKAN_HPP_NAMESPACE" )
: ( "const " + generateStandardArray( memberIt->type.compose( "VULKAN_HPP_NAMESPACE" ), memberIt->arraySizes ) + "&" ); : ( "const " + generateStandardArray( memberIt->type.compose( "VULKAN_HPP_NAMESPACE" ), memberIt->arraySizes ) + "&" );
@ -11373,10 +11353,8 @@ std::string VulkanHppGenerator::generateUnion( std::pair<std::string, StructureD
// the union member variables // the union member variables
std::string members; std::string members;
// if there's at least one Vk... type in this union, check for unrestricted unions support // if there's at least one Vk... type in this union, check for unrestricted unions support
bool needsUnrestrictedUnions = bool needsUnrestrictedUnions = std::any_of(
( std::find_if( structure.second.members.begin(), structure.second.members.begin(), structure.second.members.end(), []( MemberData const & member ) { return member.type.type.starts_with( "Vk" ); } );
structure.second.members.end(),
[]( MemberData const & member ) { return member.type.type.starts_with( "Vk" ); } ) != structure.second.members.end() );
if ( needsUnrestrictedUnions ) if ( needsUnrestrictedUnions )
{ {
members += "#ifdef VULKAN_HPP_HAS_UNRESTRICTED_UNIONS\n"; members += "#ifdef VULKAN_HPP_HAS_UNRESTRICTED_UNIONS\n";
@ -11684,9 +11662,8 @@ std::pair<std::string, std::string> VulkanHppGenerator::getPoolTypeAndName( std:
auto memberIt = std::find_if( auto memberIt = std::find_if(
structIt->second.members.begin(), structIt->second.members.end(), []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } ); structIt->second.members.begin(), structIt->second.members.end(), []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } );
assert( memberIt != structIt->second.members.end() ); assert( memberIt != structIt->second.members.end() );
assert( std::find_if( std::next( memberIt ), assert( std::none_of(
structIt->second.members.end(), std::next( memberIt ), structIt->second.members.end(), []( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } ) );
[]( MemberData const & md ) { return md.name.find( "Pool" ) != std::string::npos; } ) == structIt->second.members.end() );
return std::make_pair( memberIt->type.type, memberIt->name ); return std::make_pair( memberIt->type.type, memberIt->name );
} }
@ -11871,7 +11848,9 @@ bool VulkanHppGenerator::handleRemovalCommand( std::string const & command, std:
auto requireCommandIt = std::find( requireDataIt->commands.begin(), requireDataIt->commands.end(), command ); auto requireCommandIt = std::find( requireDataIt->commands.begin(), requireDataIt->commands.end(), command );
if ( requireCommandIt != requireDataIt->commands.end() ) if ( requireCommandIt != requireDataIt->commands.end() )
{ {
assert( std::find( std::next( requireCommandIt ), requireDataIt->commands.end(), command ) == requireDataIt->commands.end() ); assert( std::none_of( std::next( requireCommandIt ),
requireDataIt->commands.end(),
[&command]( std::string const & requireCommand ) { return requireCommand == command; } ) );
requireDataIt->commands.erase( requireCommandIt ); requireDataIt->commands.erase( requireCommandIt );
assert( !requireDataIt->commands.empty() || !requireDataIt->types.empty() ); assert( !requireDataIt->commands.empty() || !requireDataIt->types.empty() );
removed = true; removed = true;
@ -11879,7 +11858,8 @@ bool VulkanHppGenerator::handleRemovalCommand( std::string const & command, std:
#if !defined( NDEBUG ) #if !defined( NDEBUG )
for ( auto it = std::next( requireDataIt ); it != requireData.end(); ++it ) for ( auto it = std::next( requireDataIt ); it != requireData.end(); ++it )
{ {
assert( std::find( it->commands.begin(), it->commands.end(), command ) == it->commands.end() ); assert(
std::none_of( it->commands.begin(), it->commands.end(), [&command]( std::string const & requireCommand ) { return requireCommand == command; } ) );
} }
#endif #endif
} }
@ -11906,7 +11886,8 @@ bool VulkanHppGenerator::handleRemovalType( std::string const & type, std::vecto
auto requireTypeIt = std::find( requireDataIt->types.begin(), requireDataIt->types.end(), type ); auto requireTypeIt = std::find( requireDataIt->types.begin(), requireDataIt->types.end(), type );
if ( requireTypeIt != requireDataIt->types.end() ) if ( requireTypeIt != requireDataIt->types.end() )
{ {
assert( std::find( std::next( requireTypeIt ), requireDataIt->types.end(), type ) == requireDataIt->types.end() ); assert(
std::none_of( std::next( requireTypeIt ), requireDataIt->types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) );
requireDataIt->types.erase( requireTypeIt ); requireDataIt->types.erase( requireTypeIt );
requireDataIt = ( requireDataIt->commands.empty() && requireDataIt->types.empty() ) ? requireData.erase( requireDataIt ) : std::next( requireDataIt ); requireDataIt = ( requireDataIt->commands.empty() && requireDataIt->types.empty() ) ? requireData.erase( requireDataIt ) : std::next( requireDataIt );
removed = true; removed = true;
@ -11914,7 +11895,7 @@ bool VulkanHppGenerator::handleRemovalType( std::string const & type, std::vecto
#if !defined( NDEBUG ) #if !defined( NDEBUG )
for ( auto it = std::next( requireDataIt ); it != requireData.end(); ++it ) for ( auto it = std::next( requireDataIt ); it != requireData.end(); ++it )
{ {
assert( std::find( it->types.begin(), it->types.end(), type ) == it->types.end() ); assert( std::none_of( it->types.begin(), it->types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) );
} }
#endif #endif
} }
@ -12101,12 +12082,12 @@ bool VulkanHppGenerator::isSupported( std::set<std::string> const & requiredBy )
bool VulkanHppGenerator::isSupportedExtension( std::string const & name ) const bool VulkanHppGenerator::isSupportedExtension( std::string const & name ) const
{ {
return std::find_if( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } ) != m_extensions.end(); return std::any_of( m_extensions.begin(), m_extensions.end(), [&name]( ExtensionData const & ed ) { return ed.name == name; } );
} }
bool VulkanHppGenerator::isSupportedFeature( std::string const & name ) const bool VulkanHppGenerator::isSupportedFeature( std::string const & name ) const
{ {
return std::find_if( m_features.begin(), m_features.end(), [&name]( FeatureData const & fd ) { return fd.name == name; } ) != m_features.end(); return std::any_of( m_features.begin(), m_features.end(), [&name]( FeatureData const & fd ) { return fd.name == name; } );
} }
bool VulkanHppGenerator::isTypeRequired( std::string const & type ) const bool VulkanHppGenerator::isTypeRequired( std::string const & type ) const
@ -12127,7 +12108,7 @@ bool VulkanHppGenerator::isTypeUsed( std::string const & type ) const
{ {
for ( auto const & r : featureIt->requireData ) for ( auto const & r : featureIt->requireData )
{ {
if ( std::find( r.types.begin(), r.types.end(), type ) != r.types.end() ) if ( std::any_of( r.types.begin(), r.types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) )
{ {
return true; return true;
} }
@ -12140,7 +12121,7 @@ bool VulkanHppGenerator::isTypeUsed( std::string const & type ) const
{ {
for ( auto const & r : extensionIt->requireData ) for ( auto const & r : extensionIt->requireData )
{ {
if ( std::find( r.types.begin(), r.types.end(), type ) != r.types.end() ) if ( std::any_of( r.types.begin(), r.types.end(), [&type]( std::string const & requireType ) { return requireType == type; } ) )
{ {
return true; return true;
} }
@ -12159,8 +12140,7 @@ bool VulkanHppGenerator::needsStructureChainResize( std::map<size_t, VectorParam
// assert that there's no other chained vector param ! // assert that there's no other chained vector param !
assert( assert(
( it == chainedReturnParams.end() ) || ( it == chainedReturnParams.end() ) ||
( std::find_if( std::next( it ), chainedReturnParams.end(), [&vectorParams]( size_t crp ) { return vectorParams.find( crp ) != vectorParams.end(); } ) == std::none_of( std::next( it ), chainedReturnParams.end(), [&vectorParams]( size_t crp ) { return vectorParams.find( crp ) != vectorParams.end(); } ) );
chainedReturnParams.end() ) );
return ( it != chainedReturnParams.end() ); return ( it != chainedReturnParams.end() );
} }
@ -12173,24 +12153,24 @@ std::pair<bool, std::map<size_t, std::vector<size_t>>> VulkanHppGenerator::needs
std::map<size_t, std::vector<size_t>> countToVectorMap; std::map<size_t, std::vector<size_t>> countToVectorMap;
for ( auto const & vpi : vectorParams ) for ( auto const & vpi : vectorParams )
{ {
if ( ( vpi.second.lenParam != INVALID_INDEX ) && ( std::find( returnParams.begin(), returnParams.end(), vpi.first ) == returnParams.end() ) && if ( ( vpi.second.lenParam != INVALID_INDEX ) &&
std::none_of( returnParams.begin(), returnParams.end(), [&vpi]( size_t rp ) { return rp == vpi.first; } ) &&
( ( singularParams.find( vpi.second.lenParam ) == singularParams.end() ) || ( ( singularParams.find( vpi.second.lenParam ) == singularParams.end() ) ||
isLenByStructMember( params[vpi.first].lenExpression, params[vpi.second.lenParam] ) ) ) isLenByStructMember( params[vpi.first].lenExpression, params[vpi.second.lenParam] ) ) )
{ {
countToVectorMap[vpi.second.lenParam].push_back( vpi.first ); countToVectorMap[vpi.second.lenParam].push_back( vpi.first );
} }
} }
return std::make_pair( std::find_if( countToVectorMap.begin(), return std::make_pair( std::any_of( countToVectorMap.begin(),
countToVectorMap.end(), countToVectorMap.end(),
[this, &params, &skippedParams]( auto const & cvm ) [this, &params, &skippedParams]( auto const & cvm )
{ {
return ( 1 < cvm.second.size() ) || isLenByStructMember( params[cvm.second[0]].lenExpression, params[cvm.first] ) || return ( 1 < cvm.second.size() ) || isLenByStructMember( params[cvm.second[0]].lenExpression, params[cvm.first] ) ||
( std::find_if( params[cvm.second[0]].lenParams.begin(), std::none_of( params[cvm.second[0]].lenParams.begin(),
params[cvm.second[0]].lenParams.end(), params[cvm.second[0]].lenParams.end(),
[&skippedParams]( std::pair<std::string, size_t> const & lenParam ) { [&skippedParams]( std::pair<std::string, size_t> const & lenParam )
return skippedParams.find( lenParam.second ) != skippedParams.end(); { return skippedParams.find( lenParam.second ) != skippedParams.end(); } );
} ) == params[cvm.second[0]].lenParams.end() ); } ),
} ) != countToVectorMap.end(),
countToVectorMap ); countToVectorMap );
} }
@ -12389,7 +12369,7 @@ std::pair<bool, VulkanHppGenerator::ParamData> VulkanHppGenerator::readCommandPa
if ( api.empty() || ( api == m_api ) ) if ( api.empty() || ( api == m_api ) )
{ {
checkForError( std::find_if( params.begin(), params.end(), [&name = nameData.name]( ParamData const & pd ) { return pd.name == name; } ) == params.end(), checkForError( std::none_of( params.begin(), params.end(), [&name = nameData.name]( ParamData const & pd ) { return pd.name == name; } ),
line, line,
"command param <" + nameData.name + "> already used" ); "command param <" + nameData.name + "> already used" );
} }
@ -12633,10 +12613,12 @@ void VulkanHppGenerator::readExtensionRequire( tinyxml2::XMLElement const * elem
requireData.depends = tokenizeAny( attribute.second, ",+" ); requireData.depends = tokenizeAny( attribute.second, ",+" );
for ( auto const & d : requireData.depends ) for ( auto const & d : requireData.depends )
{ {
checkForError( std::find_if( extensionData.requireData.begin(), checkForError( std::none_of( extensionData.requireData.begin(),
extensionData.requireData.end(), extensionData.requireData.end(),
[&d]( RequireData const & rd ) [&d]( RequireData const & rd ) {
{ return std::find( rd.depends.begin(), rd.depends.end(), d ) != rd.depends.end(); } ) == extensionData.requireData.end(), return std::any_of(
rd.depends.begin(), rd.depends.end(), [&d]( std::string const & requireDepends ) { return requireDepends == d; } );
} ),
line, line,
"required extension <" + d + "> already listed" ); "required extension <" + d + "> already listed" );
} }
@ -12806,18 +12788,18 @@ void VulkanHppGenerator::readExtension( tinyxml2::XMLElement const * element )
} }
} }
checkForWarning( ( std::find( supported.begin(), supported.end(), "disabled" ) != supported.end() ) || extensionData.isDeprecated || ratified.empty() || checkForWarning( std::any_of( supported.begin(), supported.end(), []( std::string const & s ) { return s == "disabled"; } ) || extensionData.isDeprecated ||
( supported == ratified ), ratified.empty() || ( supported == ratified ),
line, line,
"attribute \"ratified\" differs from attribute \"supported\"" ); "attribute \"ratified\" differs from attribute \"supported\"" );
bool extensionSupported = supported.empty() || ( std::find( supported.begin(), supported.end(), m_api ) != supported.end() ); bool extensionSupported = supported.empty() || std::any_of( supported.begin(), supported.end(), [this]( std::string const & s ) { return s == m_api; } );
checkForError( !extensionSupported || !extensionData.type.empty(), line, "missing attribute \"type\" for supported extension <" + extensionData.name + ">" ); checkForError( !extensionSupported || !extensionData.type.empty(), line, "missing attribute \"type\" for supported extension <" + extensionData.name + ">" );
for ( auto child : children ) for ( auto child : children )
{ {
readExtensionRequire( child, extensionData, extensionSupported ); readExtensionRequire( child, extensionData, extensionSupported );
} }
if ( std::find( supported.begin(), supported.end(), "disabled" ) == supported.end() ) if ( std::none_of( supported.begin(), supported.end(), []( std::string const & s ) { return s == "disabled"; } ) )
{ {
// extract the tag from the name, which is supposed to look like VK_<tag>_<other> // extract the tag from the name, which is supposed to look like VK_<tag>_<other>
size_t tagStart = extensionData.name.find( '_' ); size_t tagStart = extensionData.name.find( '_' );
@ -12868,7 +12850,7 @@ void VulkanHppGenerator::readFeature( tinyxml2::XMLElement const * element )
} }
} }
bool featureSupported = std::find( api.begin(), api.end(), m_api ) != api.end(); bool featureSupported = std::any_of( api.begin(), api.end(), [this]( std::string const & a ) { return a == m_api; } );
for ( auto child : children ) for ( auto child : children )
{ {
std::string value = child->Value(); std::string value = child->Value();
@ -12882,7 +12864,9 @@ void VulkanHppGenerator::readFeature( tinyxml2::XMLElement const * element )
} }
} }
checkForError( featureData.name == ( ( std::find( api.begin(), api.end(), "vulkan" ) != api.end() ) ? "VK_VERSION_" : "VKSC_VERSION_" ) + modifiedNumber, checkForError( featureData.name ==
( std::any_of( api.begin(), api.end(), []( std::string const & a ) { return a == "vulkan"; } ) ? "VK_VERSION_" : "VKSC_VERSION_" ) +
modifiedNumber,
line, line,
"unexpected formatting of name <" + featureData.name + ">" ); "unexpected formatting of name <" + featureData.name + ">" );
checkForError( !isFeature( featureData.name ), line, "feature <" + featureData.name + "> already specified" ); checkForError( !isFeature( featureData.name ), line, "feature <" + featureData.name + "> already specified" );
@ -13054,9 +13038,9 @@ void VulkanHppGenerator::readFormat( tinyxml2::XMLElement const * element )
} }
else else
{ {
checkForError( std::find_if( formatIt->second.unsupportedValues.begin(), checkForError( std::any_of( formatIt->second.unsupportedValues.begin(),
formatIt->second.unsupportedValues.end(), formatIt->second.unsupportedValues.end(),
[&name]( EnumValueData const & evd ) { return evd.name == name; } ) != formatIt->second.unsupportedValues.end(), [&name]( EnumValueData const & evd ) { return evd.name == name; } ),
line, line,
"unknown format <" + name + ">" ); "unknown format <" + name + ">" );
} }
@ -13118,9 +13102,9 @@ void VulkanHppGenerator::readFormatPlane( tinyxml2::XMLElement const * element,
plane.compatible = attribute.second; plane.compatible = attribute.second;
auto formatIt = m_enums.find( "VkFormat" ); auto formatIt = m_enums.find( "VkFormat" );
assert( formatIt != m_enums.end() ); assert( formatIt != m_enums.end() );
checkForError( std::find_if( formatIt->second.values.begin(), checkForError( std::any_of( formatIt->second.values.begin(),
formatIt->second.values.end(), formatIt->second.values.end(),
[&plane]( EnumValueData const & evd ) { return evd.name == plane.compatible; } ) != formatIt->second.values.end(), [&plane]( EnumValueData const & evd ) { return evd.name == plane.compatible; } ),
line, line,
"encountered unknown format <" + plane.compatible + ">" ); "encountered unknown format <" + plane.compatible + ">" );
} }
@ -13236,9 +13220,9 @@ void VulkanHppGenerator::readPlatform( tinyxml2::XMLElement const * element )
} }
} }
checkForError( std::find_if( m_platforms.begin(), checkForError( std::none_of( m_platforms.begin(),
m_platforms.end(), m_platforms.end(),
[&protect]( std::pair<std::string, PlatformData> const & p ) { return p.second.protect == protect; } ) == m_platforms.end(), [&protect]( std::pair<std::string, PlatformData> const & p ) { return p.second.protect == protect; } ),
line, line,
"protect <" + protect + "> of platform <" + name + "> is already used with some other platform" ); "protect <" + protect + "> of platform <" + name + "> is already used with some other platform" );
checkForError( m_platforms.insert( { name, { protect, line } } ).second, line, "platform <" + name + "> is already specified" ); checkForError( m_platforms.insert( { name, { protect, line } } ).second, line, "platform <" + name + "> is already specified" );
@ -13586,11 +13570,10 @@ void VulkanHppGenerator::readSPIRVCapabilityEnable( tinyxml2::XMLElement const *
checkForError( checkForError(
enumIt != m_enums.end(), line, "member <" + member + "> specified for SPIR-V capability requires an unknown enum <" + bitmaskIt->second.require + ">" ); enumIt != m_enums.end(), line, "member <" + member + "> specified for SPIR-V capability requires an unknown enum <" + bitmaskIt->second.require + ">" );
checkForError( checkForError(
( std::find_if( enumIt->second.values.begin(), enumIt->second.values.end(), [&value]( EnumValueData const & evd ) { return evd.name == value; } ) != std::any_of( enumIt->second.values.begin(), enumIt->second.values.end(), [&value]( EnumValueData const & evd ) { return evd.name == value; } ) ||
enumIt->second.values.end() ) || std::any_of( enumIt->second.unsupportedValues.begin(),
( std::find_if( enumIt->second.unsupportedValues.begin(), enumIt->second.unsupportedValues.end(),
enumIt->second.unsupportedValues.end(), [&value]( EnumValueData const & evd ) { return evd.name == value; } ),
[&value]( EnumValueData const & evd ) { return evd.name == value; } ) != enumIt->second.unsupportedValues.end() ),
line, line,
"unknown attribute value <" + value + "> specified for SPIR-V capability" ); "unknown attribute value <" + value + "> specified for SPIR-V capability" );
} }
@ -13837,7 +13820,7 @@ void VulkanHppGenerator::readStructMember( tinyxml2::XMLElement const * element,
if ( api.empty() || ( api == m_api ) ) if ( api.empty() || ( api == m_api ) )
{ {
checkForError( std::find_if( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ) == members.end(), checkForError( std::none_of( members.begin(), members.end(), [&name]( MemberData const & md ) { return md.name == name; } ),
line, line,
"struct member name <" + name + "> already used" ); "struct member name <" + name + "> already used" );
memberData.name = name; memberData.name = name;
@ -13980,11 +13963,10 @@ void VulkanHppGenerator::readSyncPipeline( tinyxml2::XMLElement const * element
std::vector<std::string> depends = tokenize( attribute.second, "," ); std::vector<std::string> depends = tokenize( attribute.second, "," );
for ( auto const & d : depends ) for ( auto const & d : depends )
{ {
checkForError( checkForError( std::any_of( m_extensions.begin(), m_extensions.end(), [&d]( ExtensionData const & ed ) { return ed.name == d; } ) ||
( std::find_if( m_extensions.begin(), m_extensions.end(), [&d]( ExtensionData const & ed ) { return ed.name == d; } ) != m_extensions.end() ) || ( m_unsupportedExtensions.find( d ) != m_unsupportedExtensions.end() ),
( m_unsupportedExtensions.find( d ) != m_unsupportedExtensions.end() ), line,
line, "syncpipeline depends on unknown extension <" + d + ">" );
"syncpipeline depends on unknown extension <" + d + ">" );
} }
} }
} }
@ -14385,9 +14367,9 @@ void VulkanHppGenerator::readTypeFuncpointer( tinyxml2::XMLElement const * eleme
argumentName = argumentName.substr( argumentName.find_first_not_of( "* " ) ); argumentName = argumentName.substr( argumentName.find_first_not_of( "* " ) );
argumentName = argumentName.substr( 0, argumentName.find_first_of( ",)" ) ); argumentName = argumentName.substr( 0, argumentName.find_first_of( ",)" ) );
checkForError( std::find_if( arguments.begin(), checkForError( std::none_of( arguments.begin(),
arguments.end(), arguments.end(),
[&argumentName]( FuncPointerArgumentData const & argument ) { return argument.name == argumentName; } ) == arguments.end(), [&argumentName]( FuncPointerArgumentData const & argument ) { return argument.name == argumentName; } ),
line, line,
"argument <" + argumentName + "> already listed in funcpointer <" + name + ">" ); "argument <" + argumentName + "> already listed in funcpointer <" + name + ">" );
arguments.push_back( { argumentName, type, argumentLine } ); arguments.push_back( { argumentName, type, argumentLine } );

View File

@ -109,10 +109,9 @@ bool checkLayers( std::vector<char const *> const & layers, std::vector<vk::Laye
layers.end(), layers.end(),
[&properties]( char const * name ) [&properties]( char const * name )
{ {
return std::find_if( properties.begin(), return std::any_of( properties.begin(),
properties.end(), properties.end(),
[&name]( vk::LayerProperties const & property ) [&name]( vk::LayerProperties const & property ) { return strcmp( property.layerName, name ) == 0; } );
{ return strcmp( property.layerName, name ) == 0; } ) != properties.end();
} ); } );
} }

View File

@ -70,6 +70,7 @@ struct GeometryInstanceData
uint32_t flags : 8; // Instance flags, such as culling uint32_t flags : 8; // Instance flags, such as culling
uint64_t accelerationStructureHandle; // Opaque handle of the bottom-level acceleration structure uint64_t accelerationStructureHandle; // Opaque handle of the bottom-level acceleration structure
}; };
static_assert( sizeof( GeometryInstanceData ) == 64, "GeometryInstanceData structure compiles to incorrect size" ); static_assert( sizeof( GeometryInstanceData ) == 64, "GeometryInstanceData structure compiles to incorrect size" );
struct AccelerationStructureData struct AccelerationStructureData
@ -213,6 +214,7 @@ struct Material
glm::vec3 diffuse = glm::vec3( 0.7f, 0.7f, 0.7f ); glm::vec3 diffuse = glm::vec3( 0.7f, 0.7f, 0.7f );
int textureID = -1; int textureID = -1;
}; };
const size_t MaterialStride = ( ( sizeof( Material ) + 15 ) / 16 ) * 16; const size_t MaterialStride = ( ( sizeof( Material ) + 15 ) / 16 ) * 16;
struct Vertex struct Vertex
@ -224,6 +226,7 @@ struct Vertex
glm::vec2 texCoord; glm::vec2 texCoord;
int matID; int matID;
}; };
const size_t VertexStride = ( ( sizeof( Vertex ) + 15 ) / 16 ) * 16; const size_t VertexStride = ( ( sizeof( Vertex ) + 15 ) / 16 ) * 16;
static const std::vector<Vertex> cubeData = { static const std::vector<Vertex> cubeData = {
@ -705,10 +708,9 @@ int main( int /*argc*/, char ** /*argv*/ )
for ( auto pd : physicalDevices ) for ( auto pd : physicalDevices )
{ {
std::vector<vk::ExtensionProperties> ep = pd.enumerateDeviceExtensionProperties(); std::vector<vk::ExtensionProperties> ep = pd.enumerateDeviceExtensionProperties();
if ( std::find_if( ep.cbegin(), if ( std::any_of( ep.cbegin(),
ep.cend(), ep.cend(),
[]( vk::ExtensionProperties const & prop ) []( vk::ExtensionProperties const & prop ) { return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) )
{ return strcmp( prop.extensionName, VK_NV_RAY_TRACING_EXTENSION_NAME ) == 0; } ) != ep.cend() )
{ {
physicalDevice = pd; physicalDevice = pd;
break; break;
@ -731,11 +733,11 @@ int main( int /*argc*/, char ** /*argv*/ )
auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>(); auto supportedFeatures = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>();
vk::Device device = vk::su::createDevice( physicalDevice, vk::Device device = vk::su::createDevice( physicalDevice,
graphicsAndPresentQueueFamilyIndex.first, graphicsAndPresentQueueFamilyIndex.first,
{ VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME,
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME,
VK_KHR_MAINTENANCE_3_EXTENSION_NAME, VK_KHR_MAINTENANCE_3_EXTENSION_NAME,
VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_NV_RAY_TRACING_EXTENSION_NAME }, VK_NV_RAY_TRACING_EXTENSION_NAME },
&supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features, &supportedFeatures.get<vk::PhysicalDeviceFeatures2>().features,
&supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() ); &supportedFeatures.get<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>() );

View File

@ -238,17 +238,16 @@ namespace vk
enabledExtensions.reserve( extensions.size() ); enabledExtensions.reserve( extensions.size() );
for ( auto const & ext : extensions ) for ( auto const & ext : extensions )
{ {
assert( std::find_if( extensionProperties.begin(), assert( std::any_of(
extensionProperties.end(), extensionProperties.begin(), extensionProperties.end(), [ext]( vk::ExtensionProperties const & ep ) { return ext == ep.extensionName; } ) );
[ext]( vk::ExtensionProperties const & ep ) { return ext == ep.extensionName; } ) != extensionProperties.end() );
enabledExtensions.push_back( ext.data() ); enabledExtensions.push_back( ext.data() );
} }
#if !defined( NDEBUG ) #if !defined( NDEBUG )
if ( std::find( extensions.begin(), extensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME ) == extensions.end() && if ( std::none_of(
std::find_if( extensionProperties.begin(), extensions.begin(), extensions.end(), []( std::string const & extension ) { return extension == VK_EXT_DEBUG_UTILS_EXTENSION_NAME; } ) &&
extensionProperties.end(), std::any_of( extensionProperties.begin(),
[]( vk::ExtensionProperties const & ep ) extensionProperties.end(),
{ return ( strcmp( VK_EXT_DEBUG_UTILS_EXTENSION_NAME, ep.extensionName ) == 0 ); } ) != extensionProperties.end() ) []( vk::ExtensionProperties const & ep ) { return ( strcmp( VK_EXT_DEBUG_UTILS_EXTENSION_NAME, ep.extensionName ) == 0 ); } ) )
{ {
enabledExtensions.push_back( VK_EXT_DEBUG_UTILS_EXTENSION_NAME ); enabledExtensions.push_back( VK_EXT_DEBUG_UTILS_EXTENSION_NAME );
} }
@ -267,17 +266,15 @@ namespace vk
enabledLayers.reserve( layers.size() ); enabledLayers.reserve( layers.size() );
for ( auto const & layer : layers ) for ( auto const & layer : layers )
{ {
assert( std::find_if( layerProperties.begin(), layerProperties.end(), [layer]( vk::LayerProperties const & lp ) { return layer == lp.layerName; } ) != assert( std::any_of( layerProperties.begin(), layerProperties.end(), [layer]( vk::LayerProperties const & lp ) { return layer == lp.layerName; } ) );
layerProperties.end() );
enabledLayers.push_back( layer.data() ); enabledLayers.push_back( layer.data() );
} }
#if !defined( NDEBUG ) #if !defined( NDEBUG )
// Enable standard validation layer to find as much errors as possible! // Enable standard validation layer to find as much errors as possible!
if ( std::find( layers.begin(), layers.end(), "VK_LAYER_KHRONOS_validation" ) == layers.end() && if ( std::none_of( layers.begin(), layers.end(), []( std::string const & layer ) { return layer == "VK_LAYER_KHRONOS_validation"; } ) &&
std::find_if( layerProperties.begin(), std::any_of( layerProperties.begin(),
layerProperties.end(), layerProperties.end(),
[]( vk::LayerProperties const & lp ) []( vk::LayerProperties const & lp ) { return ( strcmp( "VK_LAYER_KHRONOS_validation", lp.layerName ) == 0 ); } ) )
{ return ( strcmp( "VK_LAYER_KHRONOS_validation", lp.layerName ) == 0 ); } ) != layerProperties.end() )
{ {
enabledLayers.push_back( "VK_LAYER_KHRONOS_validation" ); enabledLayers.push_back( "VK_LAYER_KHRONOS_validation" );
} }
@ -352,9 +349,9 @@ namespace vk
vk::AttachmentReference depthAttachment( 1, vk::ImageLayout::eDepthStencilAttachmentOptimal ); vk::AttachmentReference depthAttachment( 1, vk::ImageLayout::eDepthStencilAttachmentOptimal );
vk::SubpassDescription subpassDescription( vk::SubpassDescriptionFlags(), vk::SubpassDescription subpassDescription( vk::SubpassDescriptionFlags(),
vk::PipelineBindPoint::eGraphics, vk::PipelineBindPoint::eGraphics,
{}, {},
colorAttachment, colorAttachment,
{}, {},
( depthFormat != vk::Format::eUndefined ) ? &depthAttachment : nullptr ); ( depthFormat != vk::Format::eUndefined ) ? &depthAttachment : nullptr );
return device.createRenderPass( vk::RenderPassCreateInfo( vk::RenderPassCreateFlags(), attachmentDescriptions, subpassDescription ) ); return device.createRenderPass( vk::RenderPassCreateInfo( vk::RenderPassCreateFlags(), attachmentDescriptions, subpassDescription ) );
} }

View File

@ -2910,7 +2910,7 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_RAII_NAMESPACE::BufferCollectionFUCHSIA; using VULKAN_HPP_RAII_NAMESPACE::BufferCollectionFUCHSIA;
#endif /*VK_USE_PLATFORM_FUCHSIA*/ #endif /*VK_USE_PLATFORM_FUCHSIA*/
//=== VK_EXT_opacity_micromap === //=== VK_EXT_opacity_micromap ===
using VULKAN_HPP_RAII_NAMESPACE::MicromapEXT; using VULKAN_HPP_RAII_NAMESPACE::MicromapEXT;
//=== VK_NV_optical_flow === //=== VK_NV_optical_flow ===

View File

@ -1345,9 +1345,9 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::StructExtends; using VULKAN_HPP_NAMESPACE::StructExtends;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#if defined( VULKAN_HPP_DYNAMIC_LOADER_TOOL ) #if defined( VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL )
using VULKAN_HPP_NAMESPACE::DynamicLoader; using VULKAN_HPP_NAMESPACE::DynamicLoader;
#endif /*VULKAN_HPP_DYNAMIC_LOADER_TOOL*/ #endif /*VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL*/
using VULKAN_HPP_NAMESPACE::DispatchLoaderDynamic; using VULKAN_HPP_NAMESPACE::DispatchLoaderDynamic;
@ -1390,7 +1390,7 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::isObsoletedExtension; using VULKAN_HPP_NAMESPACE::isObsoletedExtension;
using VULKAN_HPP_NAMESPACE::isPromotedExtension; using VULKAN_HPP_NAMESPACE::isPromotedExtension;
export namespace VULKAN_HPP_RAII_NAMESPACE namespace VULKAN_HPP_RAII_NAMESPACE
{ {
//====================== //======================
//=== RAII HARDCODED === //=== RAII HARDCODED ===

View File

@ -212,6 +212,14 @@ constexpr int False = 0;
# define VULKAN_HPP_CONST_OR_CONSTEXPR const # define VULKAN_HPP_CONST_OR_CONSTEXPR const
#endif #endif
#if !defined( VULKAN_HPP_CONSTEXPR_INLINE )
# if 201606L <= __cpp_inline_variables
# define VULKAN_HPP_CONSTEXPR_INLINE VULKAN_HPP_CONSTEXPR inline
# else
# define VULKAN_HPP_CONSTEXPR_INLINE VULKAN_HPP_CONSTEXPR
# endif
#endif
#if !defined( VULKAN_HPP_NOEXCEPT ) #if !defined( VULKAN_HPP_NOEXCEPT )
# if defined( _MSC_VER ) && ( _MSC_VER <= 1800 ) # if defined( _MSC_VER ) && ( _MSC_VER <= 1800 )
# define VULKAN_HPP_NOEXCEPT # define VULKAN_HPP_NOEXCEPT
@ -4320,32 +4328,32 @@ namespace VULKAN_HPP_NAMESPACE
//========================================= //=========================================
//=== CONSTEXPR CONSTANTs AND FUNCTIONs === //=== CONSTEXPR CONSTANTs AND FUNCTIONs ===
//========================================= //=========================================
VULKAN_HPP_CONSTEXPR uint32_t AttachmentUnused = VK_ATTACHMENT_UNUSED; VULKAN_HPP_CONSTEXPR_INLINE uint32_t AttachmentUnused = VK_ATTACHMENT_UNUSED;
VULKAN_HPP_CONSTEXPR uint32_t False = VK_FALSE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t False = VK_FALSE;
VULKAN_HPP_CONSTEXPR float LodClampNone = VK_LOD_CLAMP_NONE; VULKAN_HPP_CONSTEXPR_INLINE float LodClampNone = VK_LOD_CLAMP_NONE;
VULKAN_HPP_CONSTEXPR uint32_t LuidSize = VK_LUID_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t LuidSize = VK_LUID_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t MaxDescriptionSize = VK_MAX_DESCRIPTION_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDescriptionSize = VK_MAX_DESCRIPTION_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t MaxDeviceGroupSize = VK_MAX_DEVICE_GROUP_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDeviceGroupSize = VK_MAX_DEVICE_GROUP_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t MaxDriverInfoSize = VK_MAX_DRIVER_INFO_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDriverInfoSize = VK_MAX_DRIVER_INFO_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t MaxDriverNameSize = VK_MAX_DRIVER_NAME_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxDriverNameSize = VK_MAX_DRIVER_NAME_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t MaxExtensionNameSize = VK_MAX_EXTENSION_NAME_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxExtensionNameSize = VK_MAX_EXTENSION_NAME_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t MaxGlobalPrioritySizeKhr = VK_MAX_GLOBAL_PRIORITY_SIZE_KHR; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxGlobalPrioritySizeKhr = VK_MAX_GLOBAL_PRIORITY_SIZE_KHR;
VULKAN_HPP_CONSTEXPR uint32_t MaxMemoryHeaps = VK_MAX_MEMORY_HEAPS; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxMemoryHeaps = VK_MAX_MEMORY_HEAPS;
VULKAN_HPP_CONSTEXPR uint32_t MaxMemoryTypes = VK_MAX_MEMORY_TYPES; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxMemoryTypes = VK_MAX_MEMORY_TYPES;
VULKAN_HPP_CONSTEXPR uint32_t MaxPhysicalDeviceNameSize = VK_MAX_PHYSICAL_DEVICE_NAME_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxPhysicalDeviceNameSize = VK_MAX_PHYSICAL_DEVICE_NAME_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t MaxShaderModuleIdentifierSizeExt = VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT; VULKAN_HPP_CONSTEXPR_INLINE uint32_t MaxShaderModuleIdentifierSizeExt = VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT;
VULKAN_HPP_CONSTEXPR uint32_t QueueFamilyExternal = VK_QUEUE_FAMILY_EXTERNAL; VULKAN_HPP_CONSTEXPR_INLINE uint32_t QueueFamilyExternal = VK_QUEUE_FAMILY_EXTERNAL;
VULKAN_HPP_CONSTEXPR uint32_t QueueFamilyForeignExt = VK_QUEUE_FAMILY_FOREIGN_EXT; VULKAN_HPP_CONSTEXPR_INLINE uint32_t QueueFamilyForeignExt = VK_QUEUE_FAMILY_FOREIGN_EXT;
VULKAN_HPP_CONSTEXPR uint32_t QueueFamilyIgnored = VK_QUEUE_FAMILY_IGNORED; VULKAN_HPP_CONSTEXPR_INLINE uint32_t QueueFamilyIgnored = VK_QUEUE_FAMILY_IGNORED;
VULKAN_HPP_CONSTEXPR uint32_t Remaining3DSlicesExt = VK_REMAINING_3D_SLICES_EXT; VULKAN_HPP_CONSTEXPR_INLINE uint32_t Remaining3DSlicesExt = VK_REMAINING_3D_SLICES_EXT;
VULKAN_HPP_CONSTEXPR uint32_t RemainingArrayLayers = VK_REMAINING_ARRAY_LAYERS; VULKAN_HPP_CONSTEXPR_INLINE uint32_t RemainingArrayLayers = VK_REMAINING_ARRAY_LAYERS;
VULKAN_HPP_CONSTEXPR uint32_t RemainingMipLevels = VK_REMAINING_MIP_LEVELS; VULKAN_HPP_CONSTEXPR_INLINE uint32_t RemainingMipLevels = VK_REMAINING_MIP_LEVELS;
VULKAN_HPP_CONSTEXPR uint32_t ShaderUnusedKhr = VK_SHADER_UNUSED_KHR; VULKAN_HPP_CONSTEXPR_INLINE uint32_t ShaderUnusedKhr = VK_SHADER_UNUSED_KHR;
VULKAN_HPP_CONSTEXPR uint32_t SubpassExternal = VK_SUBPASS_EXTERNAL; VULKAN_HPP_CONSTEXPR_INLINE uint32_t SubpassExternal = VK_SUBPASS_EXTERNAL;
VULKAN_HPP_CONSTEXPR uint32_t True = VK_TRUE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t True = VK_TRUE;
VULKAN_HPP_CONSTEXPR uint32_t UuidSize = VK_UUID_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint32_t UuidSize = VK_UUID_SIZE;
VULKAN_HPP_CONSTEXPR uint64_t WholeSize = VK_WHOLE_SIZE; VULKAN_HPP_CONSTEXPR_INLINE uint64_t WholeSize = VK_WHOLE_SIZE;
VULKAN_HPP_CONSTEXPR uint32_t HeaderVersion = VK_HEADER_VERSION; VULKAN_HPP_CONSTEXPR_INLINE uint32_t HeaderVersion = VK_HEADER_VERSION;
template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type> template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type>
VULKAN_HPP_CONSTEXPR uint32_t apiVersionMajor( T const version ) VULKAN_HPP_CONSTEXPR uint32_t apiVersionMajor( T const version )
@ -4405,12 +4413,12 @@ namespace VULKAN_HPP_NAMESPACE
return ( (uint32_t)(version)&0xFFFU ); return ( (uint32_t)(version)&0xFFFU );
} }
VULKAN_HPP_CONSTEXPR auto ApiVersion = makeApiVersion( 0, 1, 0, 0 ); VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion = makeApiVersion( 0, 1, 0, 0 );
VULKAN_HPP_CONSTEXPR auto ApiVersion10 = makeApiVersion( 0, 1, 0, 0 ); VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion10 = makeApiVersion( 0, 1, 0, 0 );
VULKAN_HPP_CONSTEXPR auto ApiVersion11 = makeApiVersion( 0, 1, 1, 0 ); VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion11 = makeApiVersion( 0, 1, 1, 0 );
VULKAN_HPP_CONSTEXPR auto ApiVersion12 = makeApiVersion( 0, 1, 2, 0 ); VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion12 = makeApiVersion( 0, 1, 2, 0 );
VULKAN_HPP_CONSTEXPR auto ApiVersion13 = makeApiVersion( 0, 1, 3, 0 ); VULKAN_HPP_CONSTEXPR_INLINE auto ApiVersion13 = makeApiVersion( 0, 1, 3, 0 );
VULKAN_HPP_CONSTEXPR auto HeaderVersionComplete = makeApiVersion( VKSC_API_VARIANT, 1, 0, VK_HEADER_VERSION ); VULKAN_HPP_CONSTEXPR_INLINE auto HeaderVersionComplete = makeApiVersion( VKSC_API_VARIANT, 1, 0, VK_HEADER_VERSION );
} // namespace VULKAN_HPP_NAMESPACE } // namespace VULKAN_HPP_NAMESPACE
@ -7020,7 +7028,7 @@ namespace VULKAN_HPP_NAMESPACE
# elif defined( __APPLE__ ) # elif defined( __APPLE__ )
m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL );
# elif defined( _WIN32 ) # elif defined( _WIN32 )
m_library = ::LoadLibraryA( "vulkan-1.dll" ); m_library = ::LoadLibraryA( "vulkan-1.dll" );
# else # else
# error unsupported platform # error unsupported platform
# endif # endif