Resolve issues with release build.

This commit is contained in:
asuessenbach 2021-05-25 16:14:56 +02:00
parent 5fe7d29f90
commit cb87566cdd
46 changed files with 164 additions and 48 deletions

View File

@ -260,9 +260,11 @@ namespace vk
copyToDevice( *stagingBuffer.deviceMemory, data.data(), data.size(), elementSize ); copyToDevice( *stagingBuffer.deviceMemory, data.data(), data.size(), elementSize );
vk::raii::su::oneTimeSubmit( vk::raii::su::oneTimeSubmit(
device, commandPool, queue, [&]( vk::raii::CommandBuffer const & commandBuffer ) { device,
commandBuffer.copyBuffer( **stagingBuffer.buffer, **this->buffer, vk::BufferCopy( 0, 0, dataSize ) ); commandPool,
} ); queue,
[&]( vk::raii::CommandBuffer const & commandBuffer )
{ commandBuffer.copyBuffer( **stagingBuffer.buffer, **this->buffer, vk::BufferCopy( 0, 0, dataSize ) ); } );
} }
std::unique_ptr<vk::raii::Buffer> buffer; std::unique_ptr<vk::raii::Buffer> buffer;
@ -634,10 +636,11 @@ namespace vk
std::vector<vk::DescriptorPoolSize> const & poolSizes ) std::vector<vk::DescriptorPoolSize> const & poolSizes )
{ {
assert( !poolSizes.empty() ); assert( !poolSizes.empty() );
uint32_t maxSets = std::accumulate( uint32_t maxSets = std::accumulate( poolSizes.begin(),
poolSizes.begin(), poolSizes.end(), 0, []( uint32_t sum, vk::DescriptorPoolSize const & dps ) { poolSizes.end(),
return sum + dps.descriptorCount; 0,
} ); []( uint32_t sum, vk::DescriptorPoolSize const & dps )
{ return sum + dps.descriptorCount; } );
assert( 0 < maxSets ); assert( 0 < maxSets );
vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo( vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo(
@ -853,10 +856,19 @@ namespace vk
uint32_t apiVersion = VK_API_VERSION_1_0 ) uint32_t apiVersion = VK_API_VERSION_1_0 )
{ {
vk::ApplicationInfo applicationInfo( appName.c_str(), 1, engineName.c_str(), 1, apiVersion ); vk::ApplicationInfo applicationInfo( appName.c_str(), 1, engineName.c_str(), 1, apiVersion );
std::vector<char const *> enabledLayers = std::vector<char const *> enabledLayers = vk::su::gatherLayers( layers
vk::su::gatherLayers( layers, context.enumerateInstanceLayerProperties() ); #if !defined( NDEBUG )
,
context.enumerateInstanceLayerProperties()
#endif
);
std::vector<char const *> enabledExtensions = std::vector<char const *> enabledExtensions =
vk::su::gatherExtensions( extensions, context.enumerateInstanceExtensionProperties() ); vk::su::gatherExtensions( extensions
#if !defined( NDEBUG )
,
context.enumerateInstanceExtensionProperties()
#endif
);
#if defined( NDEBUG ) #if defined( NDEBUG )
vk::StructureChain<vk::InstanceCreateInfo> vk::StructureChain<vk::InstanceCreateInfo>
#else #else

View File

@ -49,7 +49,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -59,7 +59,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroy(); device.destroy();
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -60,7 +60,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -187,7 +187,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -111,7 +111,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -90,7 +90,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -58,7 +58,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -84,7 +84,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyDescriptorSetLayout( descriptorSetLayout ); device.destroyDescriptorSetLayout( descriptorSetLayout );
uniformBufferData.clear( device ); uniformBufferData.clear( device );
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -94,7 +94,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -67,7 +67,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -83,7 +83,9 @@ int main( int /*argc*/, char ** /*argv*/ )
swapChainData.clear( device ); swapChainData.clear( device );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -132,7 +132,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -195,7 +195,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyRenderPass( renderPass ); device.destroyRenderPass( renderPass );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -203,7 +203,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -89,7 +89,9 @@ int main( int /*argc*/, char ** /*argv*/ )
usingMinorVersion = desiredMinorVersion; usingMinorVersion = desiredMinorVersion;
} }
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }

View File

@ -251,7 +251,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -153,7 +153,9 @@ int main( int /*argc*/, char ** /*argv*/ )
vk::DebugUtilsMessengerEXT debugUtilsMessenger = instance.createDebugUtilsMessengerEXT( vk::DebugUtilsMessengerEXT debugUtilsMessenger = instance.createDebugUtilsMessengerEXT(
vk::DebugUtilsMessengerCreateInfoEXT( {}, severityFlags, messageTypeFlags, &debugMessageFunc ) ); vk::DebugUtilsMessengerCreateInfoEXT( {}, severityFlags, messageTypeFlags, &debugMessageFunc ) );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */

View File

@ -66,7 +66,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyImage( image ); device.destroyImage( image );
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -211,7 +211,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -257,7 +257,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -205,7 +205,9 @@ int main( int /*argc*/, char ** /*argv*/ )
#endif #endif
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */

View File

@ -65,7 +65,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_HPP_KEY_END */ /* VULKAN_HPP_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -142,7 +142,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.freeCommandBuffers( commandPool, commandBuffer ); device.freeCommandBuffers( commandPool, commandBuffer );
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -227,7 +227,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -213,7 +213,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -306,7 +306,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -294,7 +294,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -273,7 +273,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -60,7 +60,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -810,7 +810,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -87,7 +87,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -1268,7 +1268,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -89,7 +89,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -409,7 +409,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -347,7 +347,9 @@ void main()
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -272,7 +272,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -250,7 +250,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -1407,7 +1407,9 @@ int main( int /*argc*/, char ** /*argv*/ )
} }
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surface ); instance.destroySurfaceKHR( surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
glfwDestroyWindow( window ); glfwDestroyWindow( window );

View File

@ -279,7 +279,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -296,7 +296,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -167,7 +167,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -62,7 +62,9 @@ int main( int /*argc*/, char ** /*argv*/ )
/* VULKAN_KEY_END */ /* VULKAN_KEY_END */
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -208,7 +208,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -238,7 +238,9 @@ int main( int /*argc*/, char ** /*argv*/ )
device.destroyCommandPool( commandPool ); device.destroyCommandPool( commandPool );
device.destroy(); device.destroy();
instance.destroySurfaceKHR( surfaceData.surface ); instance.destroySurfaceKHR( surfaceData.surface );
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger ); instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy(); instance.destroy();
} }
catch ( vk::SystemError & err ) catch ( vk::SystemError & err )

View File

@ -51,10 +51,10 @@ namespace vk
bool contains( std::vector<vk::ExtensionProperties> const & extensionProperties, std::string const & extensionName ) bool contains( std::vector<vk::ExtensionProperties> const & extensionProperties, std::string const & extensionName )
{ {
auto propertyIterator = std::find_if( auto propertyIterator = std::find_if( extensionProperties.begin(),
extensionProperties.begin(), extensionProperties.end(), [&extensionName]( vk::ExtensionProperties const & ep ) { extensionProperties.end(),
return extensionName == ep.extensionName; [&extensionName]( vk::ExtensionProperties const & ep )
} ); { return extensionName == ep.extensionName; } );
return ( propertyIterator != extensionProperties.end() ); return ( propertyIterator != extensionProperties.end() );
} }
@ -75,9 +75,10 @@ namespace vk
{ {
assert( !poolSizes.empty() ); assert( !poolSizes.empty() );
uint32_t maxSets = uint32_t maxSets =
std::accumulate( poolSizes.begin(), poolSizes.end(), 0, []( uint32_t sum, vk::DescriptorPoolSize const & dps ) { std::accumulate( poolSizes.begin(),
return sum + dps.descriptorCount; poolSizes.end(),
} ); 0,
[]( uint32_t sum, vk::DescriptorPoolSize const & dps ) { return sum + dps.descriptorCount; } );
assert( 0 < maxSets ); assert( 0 < maxSets );
vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo( vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo(
@ -273,16 +274,17 @@ namespace vk
enabledExtensions.reserve( extensions.size() ); enabledExtensions.reserve( extensions.size() );
for ( auto const & ext : extensions ) for ( auto const & ext : extensions )
{ {
assert( std::find_if( assert( std::find_if( extensionProperties.begin(),
extensionProperties.begin(), extensionProperties.end(), [ext]( vk::ExtensionProperties const & ep ) { extensionProperties.end(),
return ext == ep.extensionName; [ext]( vk::ExtensionProperties const & ep )
} ) != extensionProperties.end() ); { 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::find( extensions.begin(), extensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME ) == extensions.end() &&
std::find_if( std::find_if( extensionProperties.begin(),
extensionProperties.begin(), extensionProperties.end(), []( vk::ExtensionProperties const & ep ) { extensionProperties.end(),
[]( vk::ExtensionProperties const & ep ) {
return ( strcmp( VK_EXT_DEBUG_UTILS_EXTENSION_NAME, ep.extensionName ) == 0 ); return ( strcmp( VK_EXT_DEBUG_UTILS_EXTENSION_NAME, ep.extensionName ) == 0 );
} ) != extensionProperties.end() ) } ) != extensionProperties.end() )
{ {
@ -303,16 +305,18 @@ namespace vk
enabledLayers.reserve( layers.size() ); enabledLayers.reserve( layers.size() );
for ( auto const & layer : layers ) for ( auto const & layer : layers )
{ {
assert( assert( std::find_if( layerProperties.begin(),
std::find_if( layerProperties.begin(), layerProperties.end(), [layer]( vk::LayerProperties const & lp ) { layerProperties.end(),
return layer == lp.layerName; [layer]( vk::LayerProperties const & lp )
} ) != layerProperties.end() ); { 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::find( layers.begin(), layers.end(), "VK_LAYER_KHRONOS_validation" ) == layers.end() &&
std::find_if( layerProperties.begin(), layerProperties.end(), []( vk::LayerProperties const & lp ) { std::find_if( layerProperties.begin(),
layerProperties.end(),
[]( vk::LayerProperties const & lp ) {
return ( strcmp( "VK_LAYER_KHRONOS_validation", lp.layerName ) == 0 ); return ( strcmp( "VK_LAYER_KHRONOS_validation", lp.layerName ) == 0 );
} ) != layerProperties.end() ) } ) != layerProperties.end() )
{ {
@ -336,9 +340,18 @@ namespace vk
#endif #endif
vk::ApplicationInfo applicationInfo( appName.c_str(), 1, engineName.c_str(), 1, apiVersion ); vk::ApplicationInfo applicationInfo( appName.c_str(), 1, engineName.c_str(), 1, apiVersion );
std::vector<char const *> enabledLayers = vk::su::gatherLayers( layers, vk::enumerateInstanceLayerProperties() ); std::vector<char const *> enabledLayers = vk::su::gatherLayers( layers
std::vector<char const *> enabledExtensions = #if !defined( NDEBUG )
vk::su::gatherExtensions( extensions, vk::enumerateInstanceExtensionProperties() ); ,
vk::enumerateInstanceLayerProperties()
#endif
);
std::vector<char const *> enabledExtensions = vk::su::gatherExtensions( extensions
#if !defined( NDEBUG )
,
vk::enumerateInstanceExtensionProperties()
#endif
);
#if defined( NDEBUG ) #if defined( NDEBUG )
// in non-debug mode just use the InstanceCreateInfo for instance creation // in non-debug mode just use the InstanceCreateInfo for instance creation
@ -492,9 +505,9 @@ namespace vk
{ {
// get the first index into queueFamiliyProperties which supports graphics // get the first index into queueFamiliyProperties which supports graphics
std::vector<vk::QueueFamilyProperties>::const_iterator graphicsQueueFamilyProperty = std::find_if( std::vector<vk::QueueFamilyProperties>::const_iterator graphicsQueueFamilyProperty = std::find_if(
queueFamilyProperties.begin(), queueFamilyProperties.end(), []( vk::QueueFamilyProperties const & qfp ) { queueFamilyProperties.begin(),
return qfp.queueFlags & vk::QueueFlagBits::eGraphics; queueFamilyProperties.end(),
} ); []( vk::QueueFamilyProperties const & qfp ) { return qfp.queueFlags & vk::QueueFlagBits::eGraphics; } );
assert( graphicsQueueFamilyProperty != queueFamilyProperties.end() ); assert( graphicsQueueFamilyProperty != queueFamilyProperties.end() );
return static_cast<uint32_t>( std::distance( queueFamilyProperties.begin(), graphicsQueueFamilyProperty ) ); return static_cast<uint32_t>( std::distance( queueFamilyProperties.begin(), graphicsQueueFamilyProperty ) );
} }
@ -647,8 +660,9 @@ namespace vk
for ( size_t i = 0; i < sizeof( requestedFormats ) / sizeof( requestedFormats[0] ); i++ ) for ( size_t i = 0; i < sizeof( requestedFormats ) / sizeof( requestedFormats[0] ); i++ )
{ {
vk::Format requestedFormat = requestedFormats[i]; vk::Format requestedFormat = requestedFormats[i];
auto it = std::find_if( auto it = std::find_if( formats.begin(),
formats.begin(), formats.end(), [requestedFormat, requestedColorSpace]( vk::SurfaceFormatKHR const & f ) { formats.end(),
[requestedFormat, requestedColorSpace]( vk::SurfaceFormatKHR const & f ) {
return ( f.format == requestedFormat ) && ( f.colorSpace == requestedColorSpace ); return ( f.format == requestedFormat ) && ( f.colorSpace == requestedColorSpace );
} ); } );
if ( it != formats.end() ) if ( it != formats.end() )
@ -1133,7 +1147,9 @@ namespace vk
glfwContext() glfwContext()
{ {
glfwInit(); glfwInit();
glfwSetErrorCallback( []( int error, const char * msg ) { glfwSetErrorCallback(
[]( int error, const char * msg )
{
std::cerr << "glfw: " std::cerr << "glfw: "
<< "(" << error << ") " << msg << std::endl; << "(" << error << ") " << msg << std::endl;
} ); } );
@ -1174,7 +1190,7 @@ namespace vk
#if defined( NDEBUG ) #if defined( NDEBUG )
// in non-debug mode just use the InstanceCreateInfo for instance creation // in non-debug mode just use the InstanceCreateInfo for instance creation
vk::StructureChain<vk::InstanceCreateInfo> instanceCreateInfo( vk::StructureChain<vk::InstanceCreateInfo> instanceCreateInfo(
{ {}, &applicationInfo, enabledLayers, enabledExtensions } ); { {}, &applicationInfo, layers, extensions } );
#else #else
// in debug mode, addionally use the debugUtilsMessengerCallback in instance creation! // in debug mode, addionally use the debugUtilsMessengerCallback in instance creation!
vk::DebugUtilsMessageSeverityFlagsEXT severityFlags( vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagsEXT severityFlags( vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning |