diff --git a/CMakeLists.txt b/CMakeLists.txt index dfafe1cd084d4b324c233d502e301c24a5ee95e1..da150fcbeafec3be555d4bbefdab37dbdedf277f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ add_library(vkcv STATIC ${vkcv_sources}) if(MSVC) #enable multicore compilation on visual studio - target_compile_options(vkcv PRIVATE "/MP" "/openmp") + target_compile_options(vkcv PRIVATE "/MP" "/openmp" "/Zc:offsetof-") #set source groups to create proper filters in visual studio source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${vkcv_sources}) diff --git a/src/vkcv/FeatureManager.cpp b/src/vkcv/FeatureManager.cpp index bb331de113294ae6cfbabd19f5fd1be2d2966407..1ef33b1617f8d574ca72bec8f104d01c9fd280c9 100644 --- a/src/vkcv/FeatureManager.cpp +++ b/src/vkcv/FeatureManager.cpp @@ -1,26 +1,32 @@ #include "vkcv/FeatureManager.hpp" +#include <stddef.h> #include <string.h> +#include <type_traits> namespace vkcv { - + +#ifdef _MSVC_LANG +#define typeof(var) std::decay<decltype((var))>::type +#endif + #define vkcv_check_init_features2(type)\ type supported; \ vk::PhysicalDeviceFeatures2 query; \ query.setPNext(&supported); \ m_physicalDevice.getFeatures2(&query) -#define vkcv_check_feature(attribute) { \ - const char *f = reinterpret_cast<const char*>(&(features)); \ - const char *s = reinterpret_cast<const char*>(&(supported)); \ - const vk::Bool32* fb = reinterpret_cast<const vk::Bool32*>(f + offsetof(typeof(features), attribute)); \ - const vk::Bool32* sb = reinterpret_cast<const vk::Bool32*>(s + offsetof(typeof(features), attribute)); \ - if ((*fb) && (!*sb)) { \ - vkcv_log(((required)? LogLevel::ERROR : LogLevel::WARNING), \ - "Feature '" #attribute "' is not supported"); \ - return false; \ - } \ +#define vkcv_check_feature(attribute) { \ + const char *f = reinterpret_cast<const char*>(&(features)); \ + const char *s = reinterpret_cast<const char*>(&(supported)); \ + const vk::Bool32* fb = reinterpret_cast<const vk::Bool32*>(f + offsetof(typeof((features)), attribute)); \ + const vk::Bool32* sb = reinterpret_cast<const vk::Bool32*>(s + offsetof(typeof((features)), attribute)); \ + if ((*fb) && (!*sb)) { \ + vkcv_log(((required)? LogLevel::ERROR : LogLevel::WARNING), \ + "Feature '" #attribute "' is not supported"); \ + return false; \ + } \ } bool FeatureManager::checkSupport(const vk::PhysicalDevice16BitStorageFeatures &features, bool required) const {