Merge pull request #649 from mocabe/assert-on-result

Add VULKAN_HPP_ASSERT_ON_RESULT
This commit is contained in:
Andreas Süßenbach 2020-06-30 09:00:35 +02:00 committed by GitHub
commit d4774ad6e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 13 deletions

View File

@ -402,7 +402,9 @@ std::vector<LayerProperties, MyStatefulCustomAllocator> 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

View File

@ -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<T>( 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<UniqueHandle<T,D>>( result, UniqueHandle<T,D>(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<UniqueHandle<T,D>>( result, UniqueHandle<T,D>(data, deleter) );
#else
if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() )

View File

@ -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<T>( 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<UniqueHandle<T, D>>( result, UniqueHandle<T, D>( 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<UniqueHandle<T, D>>( result, UniqueHandle<T, D>( data, deleter ) );
# else
if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() )