mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Merge pull request #758 from asuessenbach/noexcept
Correct usage of noexcept on functions that need to check vector sizes.
This commit is contained in:
commit
28a18d49cb
@ -4579,37 +4579,43 @@ std::string VulkanHppGenerator::constructCommandSimpleVoid( std::string const &
|
||||
( commandData.params[vectorParamIndices.begin()->first].type.type == "void" ) )
|
||||
? "typename T, "
|
||||
: "";
|
||||
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck =
|
||||
needsVectorSizeCheck( vectorParamIndices );
|
||||
std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT";
|
||||
|
||||
if ( definition )
|
||||
{
|
||||
std::string const functionTemplate =
|
||||
R"( template <${typenameT}typename Dispatch>
|
||||
VULKAN_HPP_INLINE void ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
|
||||
VULKAN_HPP_INLINE void ${className}::${commandName}( ${argumentList} ) const ${noexcept}
|
||||
{${vectorSizeCheck}
|
||||
d.${vkCommand}( ${callArguments} );
|
||||
})";
|
||||
|
||||
str =
|
||||
replaceWithMap( functionTemplate,
|
||||
str = replaceWithMap(
|
||||
functionTemplate,
|
||||
std::map<std::string, std::string>(
|
||||
{ { "argumentList", argumentList },
|
||||
{ "callArguments", constructCallArgumentsVectors( commandData.params, vectorParamIndices ) },
|
||||
{ "className", stripPrefix( commandData.handle, "Vk" ) },
|
||||
{ "commandName", commandName },
|
||||
{ "noexcept", noexceptString },
|
||||
{ "typenameT", typenameT },
|
||||
{ "vectorSizeCheck", constructVectorSizeCheck( name, commandData, vectorParamIndices ) },
|
||||
{ "vectorSizeCheck",
|
||||
vectorSizeCheck.first ? constructVectorSizeCheck( name, commandData, vectorSizeCheck.second ) : "" },
|
||||
{ "vkCommand", name } } ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string const functionTemplate =
|
||||
R"( template <${typenameT}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
void ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT;)";
|
||||
void ${commandName}( ${argumentList} ) const ${noexcept};)";
|
||||
|
||||
str = replaceWithMap(
|
||||
functionTemplate,
|
||||
std::map<std::string, std::string>(
|
||||
{ { "argumentList", argumentList }, { "commandName", commandName }, { "typenameT", typenameT } } ) );
|
||||
str = replaceWithMap( functionTemplate,
|
||||
std::map<std::string, std::string>( { { "argumentList", argumentList },
|
||||
{ "commandName", commandName },
|
||||
{ "noexcept", noexceptString },
|
||||
{ "typenameT", typenameT } } ) );
|
||||
}
|
||||
|
||||
return str;
|
||||
@ -5043,26 +5049,13 @@ std::string VulkanHppGenerator::constructSuccessCodeList( std::vector<std::strin
|
||||
return successCodeList;
|
||||
}
|
||||
|
||||
std::string VulkanHppGenerator::constructVectorSizeCheck( std::string const & name,
|
||||
std::string
|
||||
VulkanHppGenerator::constructVectorSizeCheck( std::string const & name,
|
||||
CommandData const & commandData,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const
|
||||
std::map<size_t, std::vector<size_t>> const & countToVectorMap ) const
|
||||
{
|
||||
std::string str;
|
||||
|
||||
std::map<size_t, std::vector<size_t>> countToVectorMap;
|
||||
for ( auto const & vpi : vectorParamIndices )
|
||||
{
|
||||
if ( vpi.second != INVALID_INDEX )
|
||||
{
|
||||
countToVectorMap[vpi.second].push_back( vpi.first );
|
||||
}
|
||||
}
|
||||
|
||||
// check if there's at least one count used multiple times
|
||||
if ( std::find_if( countToVectorMap.begin(), countToVectorMap.end(), []( auto const & cvm ) {
|
||||
return 1 < cvm.second.size();
|
||||
} ) != countToVectorMap.end() )
|
||||
{
|
||||
std::string const assertTemplate =
|
||||
" VULKAN_HPP_ASSERT( ${zeroSizeCheck}${firstVectorName}.size() == ${secondVectorName}.size() );";
|
||||
std::string const throwTemplate =
|
||||
@ -5090,8 +5083,8 @@ std::string VulkanHppGenerator::constructVectorSizeCheck( std::string const &
|
||||
{ { "firstVectorName", firstVectorName },
|
||||
{ "secondVectorName", secondVectorName },
|
||||
{ "zeroSizeCheck", withZeroSizeCheck ? ( secondVectorName + ".empty() || " ) : "" } } );
|
||||
throws += replaceWithMap(
|
||||
throwTemplate,
|
||||
throws +=
|
||||
replaceWithMap( throwTemplate,
|
||||
{ { "firstVectorName", firstVectorName },
|
||||
{ "className", stripPrefix( commandData.handle, "Vk" ) },
|
||||
{ "commandName", commandName },
|
||||
@ -5115,7 +5108,6 @@ ${throws}
|
||||
)#";
|
||||
|
||||
str = replaceWithMap( sizeCheckTemplate, { { "assertions", assertions }, { "throws", throws } } );
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
@ -6855,6 +6847,24 @@ bool VulkanHppGenerator::needsComplexBody( CommandData const & commandData ) con
|
||||
!generateProtection( commandData.feature, commandData.extensions ).first.empty();
|
||||
}
|
||||
|
||||
std::pair<bool, std::map<size_t, std::vector<size_t>>>
|
||||
VulkanHppGenerator::needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParamIndices ) const
|
||||
{
|
||||
std::map<size_t, std::vector<size_t>> countToVectorMap;
|
||||
for ( auto const & vpi : vectorParamIndices )
|
||||
{
|
||||
if ( vpi.second != INVALID_INDEX )
|
||||
{
|
||||
countToVectorMap[vpi.second].push_back( vpi.first );
|
||||
}
|
||||
}
|
||||
return std::make_pair( std::find_if( countToVectorMap.begin(),
|
||||
countToVectorMap.end(),
|
||||
[]( auto const & cvm ) { return 1 < cvm.second.size(); } ) !=
|
||||
countToVectorMap.end(),
|
||||
countToVectorMap );
|
||||
}
|
||||
|
||||
void VulkanHppGenerator::readBaseType( tinyxml2::XMLElement const * element,
|
||||
std::map<std::string, std::string> const & attributes )
|
||||
{
|
||||
@ -10092,6 +10102,11 @@ int main( int argc, char ** argv )
|
||||
# else
|
||||
# define VULKAN_HPP_NOEXCEPT noexcept
|
||||
# define VULKAN_HPP_HAS_NOEXCEPT 1
|
||||
# if defined(VULKAN_HPP_NO_EXCEPTIONS)
|
||||
# define VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS noexcept
|
||||
# else
|
||||
# define VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -630,7 +630,7 @@ private:
|
||||
std::string constructSuccessCodeList( std::vector<std::string> const & successCodes ) const;
|
||||
std::string constructVectorSizeCheck( std::string const & name,
|
||||
CommandData const & commandData,
|
||||
std::map<size_t, size_t> const & vectorParamIndices ) const;
|
||||
std::map<size_t, std::vector<size_t>> const & countToVectorMap ) const;
|
||||
void checkCorrectness();
|
||||
bool containsArray( std::string const & type ) const;
|
||||
bool containsUnion( std::string const & type ) const;
|
||||
@ -664,6 +664,8 @@ private:
|
||||
bool isParamIndirect( std::string const & name, std::vector<ParamData> const & params ) const;
|
||||
bool isTwoStepAlgorithm( std::vector<ParamData> const & params ) const;
|
||||
bool needsComplexBody( CommandData const & commandData ) const;
|
||||
std::pair<bool, std::map<size_t, std::vector<size_t>>>
|
||||
needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParamIndices ) const;
|
||||
void readBaseType( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes );
|
||||
void readBitmask( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes );
|
||||
void readBitmaskAlias( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes );
|
||||
|
@ -174,6 +174,11 @@ static_assert( VK_HEADER_VERSION == 155, "Wrong VK_HEADER_VERSION!" );
|
||||
# else
|
||||
# define VULKAN_HPP_NOEXCEPT noexcept
|
||||
# define VULKAN_HPP_HAS_NOEXCEPT 1
|
||||
# if defined( VULKAN_HPP_NO_EXCEPTIONS )
|
||||
# define VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS noexcept
|
||||
# else
|
||||
# define VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -37942,7 +37947,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & counterBufferOffsets
|
||||
VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const
|
||||
VULKAN_HPP_NOEXCEPT;
|
||||
VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
@ -38003,7 +38008,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::Buffer> const & buffers,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & offsets,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & sizes VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
@ -38017,7 +38022,8 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
void bindVertexBuffers( uint32_t firstBinding,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::Buffer> const & buffers,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & offsets,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const
|
||||
VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
@ -38037,7 +38043,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & offsets,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & sizes VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & strides VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
@ -38100,7 +38106,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
void buildAccelerationStructureKHR(
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildGeometryInfoKHR> const & infos,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildOffsetInfoKHR * const> const & pOffsetInfos,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
|
||||
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
#endif /*VK_ENABLE_BETA_EXTENSIONS*/
|
||||
|
||||
@ -38549,12 +38555,12 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
void
|
||||
endTransformFeedbackEXT( uint32_t firstCounterBuffer,
|
||||
void endTransformFeedbackEXT( uint32_t firstCounterBuffer,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::Buffer> const & counterBuffers,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & counterBufferOffsets
|
||||
VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const
|
||||
VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
@ -55478,7 +55484,8 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
void setHdrMetadataEXT( ArrayProxy<const VULKAN_HPP_NAMESPACE::SwapchainKHR> const & swapchains,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::HdrMetadataEXT> const & metadata,
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
|
||||
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const
|
||||
VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS;
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
||||
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
||||
@ -89447,7 +89454,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
uint32_t firstCounterBuffer,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::Buffer> const & counterBuffers,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & counterBufferOffsets,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
{
|
||||
# ifdef VULKAN_HPP_NO_EXCEPTIONS
|
||||
VULKAN_HPP_ASSERT( counterBufferOffsets.empty() || counterBuffers.size() == counterBufferOffsets.size() );
|
||||
@ -89576,7 +89583,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::Buffer> const & buffers,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & offsets,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & sizes,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
{
|
||||
# ifdef VULKAN_HPP_NO_EXCEPTIONS
|
||||
VULKAN_HPP_ASSERT( buffers.size() == offsets.size() );
|
||||
@ -89623,7 +89630,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
CommandBuffer::bindVertexBuffers( uint32_t firstBinding,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::Buffer> const & buffers,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & offsets,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
{
|
||||
# ifdef VULKAN_HPP_NO_EXCEPTIONS
|
||||
VULKAN_HPP_ASSERT( buffers.size() == offsets.size() );
|
||||
@ -89669,7 +89676,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & offsets,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & sizes,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & strides,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
{
|
||||
# ifdef VULKAN_HPP_NO_EXCEPTIONS
|
||||
VULKAN_HPP_ASSERT( buffers.size() == offsets.size() );
|
||||
@ -89816,7 +89823,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
VULKAN_HPP_INLINE void CommandBuffer::buildAccelerationStructureKHR(
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildGeometryInfoKHR> const & infos,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::AccelerationStructureBuildOffsetInfoKHR * const> const & pOffsetInfos,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
{
|
||||
# ifdef VULKAN_HPP_NO_EXCEPTIONS
|
||||
VULKAN_HPP_ASSERT( infos.size() == pOffsetInfos.size() );
|
||||
@ -90663,7 +90670,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
uint32_t firstCounterBuffer,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::Buffer> const & counterBuffers,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::DeviceSize> const & counterBufferOffsets,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
{
|
||||
# ifdef VULKAN_HPP_NO_EXCEPTIONS
|
||||
VULKAN_HPP_ASSERT( counterBufferOffsets.empty() || counterBuffers.size() == counterBufferOffsets.size() );
|
||||
@ -99847,7 +99854,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
VULKAN_HPP_INLINE void
|
||||
Device::setHdrMetadataEXT( ArrayProxy<const VULKAN_HPP_NAMESPACE::SwapchainKHR> const & swapchains,
|
||||
ArrayProxy<const VULKAN_HPP_NAMESPACE::HdrMetadataEXT> const & metadata,
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
|
||||
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS
|
||||
{
|
||||
# ifdef VULKAN_HPP_NO_EXCEPTIONS
|
||||
VULKAN_HPP_ASSERT( swapchains.size() == metadata.size() );
|
||||
|
Loading…
Reference in New Issue
Block a user