@@ -92,28 +92,52 @@ VkInstance create_instance(const RuntimeConfig& config) {
92
92
std::vector<const char *> enabled_layers;
93
93
std::vector<const char *> enabled_extensions;
94
94
95
+ std::vector<const char *> requested_layers;
96
+ std::vector<const char *> requested_extensions;
97
+
95
98
if (config.enable_validation_messages ) {
96
- std::vector<const char *> requested_layers{
97
- // "VK_LAYER_LUNARG_api_dump",
98
- " VK_LAYER_KHRONOS_validation" ,
99
- };
100
- std::vector<const char *> requested_extensions{
99
+ requested_layers.emplace_back (" VK_LAYER_KHRONOS_validation" );
101
100
#ifdef VK_EXT_debug_report
102
- VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
101
+ requested_extensions. emplace_back ( VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
103
102
#endif /* VK_EXT_debug_report */
104
- };
105
-
106
- find_requested_layers_and_extensions (
107
- enabled_layers,
108
- enabled_extensions,
109
- requested_layers,
110
- requested_extensions);
111
103
}
112
104
105
+ VkInstanceCreateFlags instance_flags = 0 ;
106
+ #ifdef __APPLE__
107
+ instance_flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
108
+ requested_extensions.emplace_back (
109
+ VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
110
+ #endif
111
+
112
+ find_requested_layers_and_extensions (
113
+ enabled_layers,
114
+ enabled_extensions,
115
+ requested_layers,
116
+ requested_extensions);
117
+
118
+ const void * instance_create_next = nullptr ;
119
+ // VkConfig on Mac platforms does not expose debugPrintf settings for whatever
120
+ // reason so it has to be enabled manually.
121
+ #if defined(__APPLE__) && defined(VULKAN_DEBUG)
122
+ std::vector<VkValidationFeatureEnableEXT> enabled_validation_features{
123
+ VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT,
124
+ };
125
+ VkValidationFeaturesEXT validation_features = {
126
+ VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT, // sType
127
+ nullptr , // pNext
128
+ static_cast <uint32_t >(
129
+ enabled_validation_features.size ()), // enabledValidationFeatureCount
130
+ enabled_validation_features.data (), // pEnabledValidationFeatures
131
+ 0 ,
132
+ nullptr , // pDisabledValidationFeatures
133
+ };
134
+ instance_create_next = &validation_features;
135
+ #endif /* __APPLE__ && VULKAN_DEBUG */
136
+
113
137
const VkInstanceCreateInfo instance_create_info{
114
138
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
115
- nullptr , // pNext
116
- 0u , // flags
139
+ instance_create_next , // pNext
140
+ instance_flags , // flags
117
141
&application_info, // pApplicationInfo
118
142
static_cast <uint32_t >(enabled_layers.size ()), // enabledLayerCount
119
143
enabled_layers.data (), // ppEnabledLayerNames
0 commit comments