From 2e95313c1d3dcce9bcb86135cef855a927e60461 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Tue, 20 Oct 2020 09:55:19 +0200 Subject: [PATCH] fix some warnings (errors) on release build. --- VulkanHppGenerator.cpp | 4 ++++ samples/utils/shaders.cpp | 6 ++++-- samples/utils/utils.cpp | 6 +++--- samples/utils/utils.hpp | 4 ++-- tests/Hash/Hash.cpp | 8 ++++++++ vulkan/vulkan.hpp | 4 ++++ 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index d446e9f..137f7cd 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -11456,6 +11456,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); + ignore(successCodes); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() ) @@ -11471,6 +11472,7 @@ namespace std { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore(message); + ignore(successCodes); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() ) @@ -11508,6 +11510,7 @@ namespace std { # ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); + ignore(successCodes); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() ) @@ -11544,6 +11547,7 @@ namespace std { # ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); + ignore(successCodes); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() ) diff --git a/samples/utils/shaders.cpp b/samples/utils/shaders.cpp index 34c74b3..7646a75 100644 --- a/samples/utils/shaders.cpp +++ b/samples/utils/shaders.cpp @@ -91,8 +91,10 @@ namespace vk std::string const & shaderText ) { std::vector shaderSPV; - bool ok = GLSLtoSPV( shaderStage, shaderText, shaderSPV ); - assert( ok ); + if ( !GLSLtoSPV( shaderStage, shaderText, shaderSPV ) ) + { + throw std::runtime_error( "Could not convert glsl shader to spir-v -> terminating" ); + } return device->createShaderModuleUnique( vk::ShaderModuleCreateInfo( vk::ShaderModuleCreateFlags(), shaderSPV ) ); } diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index 13e0042..b85c69f 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -1016,7 +1016,7 @@ namespace vk MonochromeImageGenerator::MonochromeImageGenerator( std::array const & rgb ) : m_rgb( rgb ) {} - void MonochromeImageGenerator::operator()( void * data, vk::Extent2D & extent ) const + void MonochromeImageGenerator::operator()( void * data, vk::Extent2D const & extent ) const { // fill in with the monochrome color unsigned char * pImageMemory = static_cast( data ); @@ -1041,10 +1041,10 @@ namespace vk assert( m_channels == 4 ); } - void PixelsImageGenerator::operator()( void * data, vk::Extent2D & extent ) const + void PixelsImageGenerator::operator()( void * data, vk::Extent2D const & extent ) const { assert( extent == m_extent ); - memcpy( data, m_pixels, m_extent.width * m_extent.height * m_channels ); + memcpy( data, m_pixels, extent.width * extent.height * m_channels ); } TextureData::TextureData( vk::PhysicalDevice const & physicalDevice, diff --git a/samples/utils/utils.hpp b/samples/utils/utils.hpp index b555e53..fee32cb 100644 --- a/samples/utils/utils.hpp +++ b/samples/utils/utils.hpp @@ -245,7 +245,7 @@ namespace vk public: MonochromeImageGenerator( std::array const & rgb ); - void operator()( void * data, vk::Extent2D & extent ) const; + void operator()( void * data, vk::Extent2D const & extent ) const; private: std::array const & m_rgb; @@ -256,7 +256,7 @@ namespace vk public: PixelsImageGenerator( vk::Extent2D const & extent, size_t channels, unsigned char const * pixels ); - void operator()( void * data, vk::Extent2D & extent ) const; + void operator()( void * data, vk::Extent2D const & extent ) const; private: vk::Extent2D m_extent; diff --git a/tests/Hash/Hash.cpp b/tests/Hash/Hash.cpp index 57bc25f..31bcb88 100644 --- a/tests/Hash/Hash.cpp +++ b/tests/Hash/Hash.cpp @@ -15,6 +15,14 @@ // VulkanHpp Samples : Hash // Compile test on using std::hash on handles +#if defined( _MSC_VER ) +# pragma warning( disable : 4189 ) // local variable is initialized but not referenced +#elif defined( __GNUC__ ) +# pragma GCC diagnostic ignored "-Wunused-variable" +#else +// unknow compiler... just ignore the warnings for yourselves ;) +#endif + #include "vulkan/vulkan.hpp" #include diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index c99125c..da898b4 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -16696,6 +16696,7 @@ namespace VULKAN_HPP_NAMESPACE { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); + ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() ) @@ -16712,6 +16713,7 @@ namespace VULKAN_HPP_NAMESPACE { #ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); + ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() ) @@ -16750,6 +16752,7 @@ namespace VULKAN_HPP_NAMESPACE { # ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); + ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() ) @@ -16786,6 +16789,7 @@ namespace VULKAN_HPP_NAMESPACE { # ifdef VULKAN_HPP_NO_EXCEPTIONS ignore( message ); + ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty 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() )