Skip to content
Snippets Groups Projects
Verified Commit 4435b8aa authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#101] Fix for MSVC

parent 8f0e83dc
No related branches found
No related tags found
No related merge requests found
Pipeline #26597 failed
......@@ -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})
......
#include "vkcv/FeatureManager.hpp"
#include <stddef.h>
#include <string.h>
namespace vkcv {
#ifdef _MSVC_LANG
#define typeof(type) decltype((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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment