diff --git a/README.md b/README.md index 97ef537..a5cdc79 100644 --- a/README.md +++ b/README.md @@ -402,7 +402,9 @@ std::vector properties = physicalDev ### Custom assertions -All over vulkan.hpp, there are a couple of calls to an assert function. By defining VULKAN_HPP_ASSERT, you can specifiy your own custom assert function to be called instead. +All over vulkan.hpp, there are a couple of calls to an assert function. By defining `VULKAN_HPP_ASSERT`, you can specifiy your own custom assert function to be called instead. + +By default, `VULKAN_HPP_ASSERT_ON_RESULT` will be used for checking results when `VULKAN_HPP_NO_EXCEPTIONS` is defined. If you want to handle errors by yourself, you can disable/customize it just like `VULKAN_HPP_ASSERT`. ### Extensions / Per Device function pointers diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 68b0fbd..94bff30 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -7974,6 +7974,10 @@ int main( int argc, char ** argv ) # define VULKAN_HPP_ASSERT assert #endif +#if !defined(VULKAN_HPP_ASSERT_ON_RESULT) +# define VULKAN_HPP_ASSERT_ON_RESULT VULKAN_HPP_ASSERT +#endif + #if !defined(VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL) # define VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL 1 #endif @@ -8122,7 +8126,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); - VULKAN_HPP_ASSERT( result == Result::eSuccess ); + VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); return result; #else if ( result != Result::eSuccess ) @@ -8137,7 +8141,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); - VULKAN_HPP_ASSERT( result == Result::eSuccess ); + VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); return ResultValue( result, std::move( data ) ); #else if ( result != Result::eSuccess ) @@ -8152,7 +8156,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); + VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); #else if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) { @@ -8167,7 +8171,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); + VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); #else if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) { @@ -8183,7 +8187,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); - VULKAN_HPP_ASSERT( result == Result::eSuccess ); + VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); return ResultValue>( result, UniqueHandle(data, deleter) ); #else if ( result != Result::eSuccess ) @@ -8199,7 +8203,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); + VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); return ResultValue>( result, UniqueHandle(data, deleter) ); #else if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index b7dcc0f..38b21ce 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -57,6 +57,10 @@ # define VULKAN_HPP_ASSERT assert #endif +#if !defined( VULKAN_HPP_ASSERT_ON_RESULT ) +# define VULKAN_HPP_ASSERT_ON_RESULT VULKAN_HPP_ASSERT +#endif + #if !defined( VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL ) # define VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL 1 #endif @@ -16144,7 +16148,7 @@ namespace VULKAN_HPP_NAMESPACE { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); - VULKAN_HPP_ASSERT( result == Result::eSuccess ); + VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); return result; #else if ( result != Result::eSuccess ) @@ -16159,7 +16163,7 @@ namespace VULKAN_HPP_NAMESPACE { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); - VULKAN_HPP_ASSERT( result == Result::eSuccess ); + VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); return ResultValue( result, std::move( data ) ); #else if ( result != Result::eSuccess ) @@ -16176,7 +16180,7 @@ namespace VULKAN_HPP_NAMESPACE { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); + VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); #else if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) { @@ -16192,7 +16196,7 @@ namespace VULKAN_HPP_NAMESPACE { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); + VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); #else if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) { @@ -16209,7 +16213,7 @@ namespace VULKAN_HPP_NAMESPACE { # ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); - VULKAN_HPP_ASSERT( result == Result::eSuccess ); + VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); return ResultValue>( result, UniqueHandle( data, deleter ) ); # else if ( result != Result::eSuccess ) @@ -16230,7 +16234,7 @@ namespace VULKAN_HPP_NAMESPACE { # ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); - VULKAN_HPP_ASSERT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); + VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); return ResultValue>( result, UniqueHandle( data, deleter ) ); # else if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() )