@@ -276,6 +276,141 @@ bool Configurator::WriteLoaderSettings(OverrideArea override_area, const Path& l
276276 }
277277}
278278
279+ bool Configurator::Export (const Path& export_path) const {
280+ QFile file (export_path.AbsolutePath ().c_str ());
281+
282+ const bool result_layers_file = file.open (QIODevice::WriteOnly | QIODevice::Text);
283+ if (!result_layers_file) {
284+ return false ;
285+ }
286+
287+ bool has_missing_layers = false ;
288+ const Configuration* configuration = this ->GetActiveConfiguration ();
289+
290+ QTextStream stream (&file);
291+
292+ stream << " Layers Settings:\n " ;
293+
294+ // Loop through all the layers
295+ for (std::size_t j = 0 , n = configuration->parameters .size (); j < n; ++j) {
296+ const Parameter& parameter = configuration->parameters [j];
297+ if (!parameter.override_settings ) {
298+ continue ;
299+ }
300+
301+ if (!(parameter.platform_flags & (1 << VKC_PLATFORM ))) {
302+ continue ;
303+ }
304+
305+ if (parameter.builtin == LAYER_BUILTIN_UNORDERED ) {
306+ continue ;
307+ }
308+
309+ if (parameter.control == LAYER_CONTROL_DISCARD || parameter.control == LAYER_CONTROL_OFF ) {
310+ continue ;
311+ }
312+
313+ const Layer* layer = this ->layers .Find (parameter.key .c_str (), parameter.api_version );
314+ if (layer == nullptr ) {
315+ if (parameter.control == LAYER_CONTROL_ON ) {
316+ has_missing_layers = true ;
317+ fprintf (stderr,
318+ " vkconfig: [ERROR] `%s` layer is set to `%s` in `%s` loader configuration but missing and being "
319+ " ignored\n " ,
320+ parameter.key .c_str (), ::GetLabel (parameter.control ), configuration->key .c_str ());
321+ } else {
322+ fprintf (stderr,
323+ " vkconfig: [WARNING] `%s` layer is set to `%s` in `%s` loader configuration but missing and being "
324+ " ignored\n " ,
325+ parameter.key .c_str (), ::GetLabel (parameter.control ), configuration->key .c_str ());
326+ }
327+ continue ;
328+ }
329+
330+ stream << " \n " ;
331+ stream << " #! " << layer->key .c_str () << " " << layer->api_version .str ().c_str () << " \n\n " ;
332+
333+ std::string lc_layer_name = GetLayerSettingPrefix (layer->key );
334+
335+ for (std::size_t i = 0 , m = parameter.settings .size (); i < m; ++i) {
336+ const SettingData* setting_data = parameter.settings [i];
337+
338+ // Skip groups - they aren't settings, so not relevant in this output
339+ if (setting_data->type == SETTING_GROUP ) {
340+ continue ;
341+ }
342+
343+ // Skip missing settings
344+ const SettingMeta* meta = FindSetting (layer->settings , setting_data->key .c_str ());
345+ if (meta == nullptr ) {
346+ continue ;
347+ }
348+
349+ // Skip overriden settings
350+ if (::CheckSettingOverridden (*meta)) {
351+ continue ;
352+ }
353+
354+ stream << " #! " ;
355+ stream << meta->label .c_str ();
356+ stream << " \n #! =====================\n " ;
357+ stream << " #! " << meta->key .c_str ();
358+
359+ if (meta->status != STATUS_STABLE ) {
360+ stream << format (" (%s)" , GetToken (meta->status )).c_str ();
361+ }
362+
363+ stream << " \n " ;
364+
365+ // Break up description into smaller words
366+ std::string description = meta->description ;
367+ std::vector<std::string> words;
368+ std::size_t pos;
369+ while ((pos = description.find (" " )) != std::string::npos) {
370+ words.push_back (description.substr (0 , pos));
371+ description.erase (0 , pos + 1 );
372+ }
373+ if (description.size () > 0 ) words.push_back (description);
374+ if (words.size () > 0 ) {
375+ stream << " #" ;
376+ std::size_t nchars = 2 ;
377+ for (auto word : words) {
378+ if (word.size () + nchars > 80 ) {
379+ stream << " \n #!" ;
380+ nchars = 3 ;
381+ }
382+ stream << " " << word.c_str ();
383+ nchars += (word.size () + 1 );
384+ }
385+ }
386+ stream << " \n " ;
387+
388+ // If feature has unmet dependency, output it but comment it out
389+ if (::CheckDependence (*meta, parameter.settings ) != SETTING_DEPENDENCE_ENABLE ) {
390+ stream << " #!" ;
391+ }
392+
393+ if (meta->status == STATUS_DEPRECATED && !meta->deprecated_by_key .empty ()) {
394+ const SettingMeta* replaced_setting = FindSetting (layer->settings , meta->deprecated_by_key .c_str ());
395+
396+ stream << format (" #! This setting was deprecated and replaced by '%s' (%s) setting.\n " ,
397+ replaced_setting->label .c_str (), replaced_setting->key .c_str ())
398+ .c_str ();
399+ }
400+
401+ std::vector<std::string> data = ::BuildEnvVariablesList (layer->key .c_str (), setting_data->key .c_str (), false );
402+
403+ stream << data[0 ].c_str () << " =" ;
404+ stream << setting_data->Export (EXPORT_MODE_OVERRIDE ).c_str ();
405+ stream << " \n\n " ;
406+ }
407+ }
408+
409+ file.close ();
410+
411+ return true ;
412+ }
413+
279414// Create and write vk_layer_settings.txt file
280415bool Configurator::WriteLayersSettings (OverrideArea override_area, const Path& layers_settings_path) {
281416 if (override_area & OVERRIDE_AREA_LAYERS_SETTINGS_BIT ) {
0 commit comments