@@ -175,7 +175,7 @@ bool LayerManager::Load(const QJsonObject &json_root_object, ConfiguratorMode co
175175 LayerDisplay layer;
176176 layer.id .manifest_path = json_layers_found_keys[i].toStdString ();
177177 layer.descriptor .enabled = !json_status_object.value (" disabled" ).toBool ();
178- layer.descriptor .validated = json_status_object. value ( " validated " ). toBool () ;
178+ layer.descriptor .validated = LAYER_VALIDATE_NONE ;
179179
180180 std::vector<LayerDisplay> layers;
181181 layers.push_back (layer);
@@ -391,7 +391,7 @@ const Layer *LayerManager::FindLastModified(const std::string &layer_name, const
391391 }
392392
393393 if (result != nullptr ) {
394- if (result->last_modified > this ->available_layers [i].last_modified ) {
394+ if (result->descriptor . last_modified > this ->available_layers [i]. descriptor .last_modified ) {
395395 continue ;
396396 }
397397 }
@@ -497,10 +497,10 @@ void LayerManager::LoadAllInstalledLayers(ConfiguratorMode configurator_mode) {
497497 }
498498 }
499499
500- this ->ApplyLayerDescriptor ();
500+ // this->ApplyLayerDescriptor();
501501}
502502
503- bool LayerManager::Validate (const Path &layer_path, QString json_text, ConfiguratorMode configurator_mode) const {
503+ LayerValidated LayerManager::Validate (const Path &layer_path, QString json_text, ConfiguratorMode configurator_mode) const {
504504 JsonValidator validator;
505505 bool result = validator.Check (json_text);
506506
@@ -543,13 +543,25 @@ bool LayerManager::Validate(const Path &layer_path, QString json_text, Configura
543543 }
544544 }
545545
546- return result;
546+ return result ? LAYER_VALIDATE_PASS : LAYER_VALIDATE_FAIL ;
547547}
548548
549- LayerLoadStatus LayerManager::LoadLayers (const Path &layer_path, LayerType type, ConfiguratorMode configurator_mode) {
550- const std::string &last_modified = layer_path.LastModified ();
551- LayerDescriptor descriptor;
549+ LayerDescriptor LayerManager::GetDescriptor (const Path &layer_path, const std::string &layer_key) const {
550+ auto it = layer_init.find (layer_path);
551+ if (it != layer_init.end ()) {
552+ const std::vector<LayerDisplay> &data = it->second ;
553+ for (std::size_t i = 0 , n = data.size (); i < n; ++i) {
554+ const LayerDisplay &display = data[i];
555+ if (display.id .key == layer_key) {
556+ return display.descriptor ;
557+ }
558+ }
559+ }
560+
561+ return LayerDescriptor ();
562+ }
552563
564+ LayerLoadStatus LayerManager::LoadLayers (const Path &layer_path, LayerType type, ConfiguratorMode configurator_mode) {
553565 QFile file (layer_path.AbsolutePath ().c_str ());
554566 if (!file.open (QIODevice::ReadOnly | QIODevice::Text)) {
555567 assert (0 );
@@ -579,6 +591,7 @@ LayerLoadStatus LayerManager::LoadLayers(const Path &layer_path, LayerType type,
579591 }
580592
581593 LayerLoadStatus status = LAYER_LOAD_ADDED ;
594+ const std::string &last_modified = layer_path.LastModified ();
582595
583596 if (json_root_object.value (" layers" ) != QJsonValue::Undefined) {
584597 const QJsonArray &json_layers_array = json_root_object.value (" layers" ).toArray ();
@@ -589,32 +602,37 @@ LayerLoadStatus LayerManager::LoadLayers(const Path &layer_path, LayerType type,
589602 std::string key = ReadStringValue (json_layer_object, " name" );
590603
591604 if (key == " VK_LAYER_LUNARG_override" || !(key.rfind (" VK_" , 0 ) == 0 )) {
592- return LAYER_LOAD_IGNORED ;
605+ status = LAYER_LOAD_IGNORED ;
606+ continue ;
593607 }
594- }
595608
596- if (this ->validate_manifests ) {
597- descriptor.validated = this ->Validate (layer_path, json_text, configurator_mode);
598- }
609+ LayerDescriptor descriptor = this ->GetDescriptor (layer_path, key);
599610
600- for (int i = 0 , n = json_layers_array.size (); i < n; ++i) {
601- const QJsonObject &json_layer_object = json_layers_array[i].toObject ();
602- status = this ->LoadLayer (json_layer_object, layer_path, type, last_modified, file_format_version, descriptor);
611+ if (this ->validate_manifests && (descriptor.last_modified != last_modified) || !descriptor.validated ) {
612+ descriptor.validated = this ->Validate (layer_path, json_text, configurator_mode);
613+ descriptor.last_modified = last_modified;
614+ }
615+
616+ status = this ->LoadLayer (json_layer_object, layer_path, type, file_format_version, descriptor);
603617 }
604618 } else if (json_root_object.value (" layer" ) != QJsonValue::Undefined) {
605619 const QJsonObject &json_layer_object = json_root_object.value (" layer" ).toObject ();
606620
607- std::string key = ReadStringValue (json_layer_object, " name" );
621+ std::string layer_key = ReadStringValue (json_layer_object, " name" );
608622
609- if (key == " VK_LAYER_LUNARG_override" || !(key .rfind (" VK_" , 0 ) == 0 )) {
623+ if (layer_key == " VK_LAYER_LUNARG_override" || !(layer_key .rfind (" VK_" , 0 ) == 0 )) {
610624 return LAYER_LOAD_IGNORED ;
611625 }
612626
613- if (this ->validate_manifests ) {
627+ LayerDescriptor descriptor = this ->GetDescriptor (layer_path, layer_key);
628+
629+ if (this ->validate_manifests &&
630+ (descriptor.last_modified != last_modified || descriptor.validated == LAYER_VALIDATE_NONE )) {
614631 descriptor.validated = this ->Validate (layer_path, json_text, configurator_mode);
632+ descriptor.last_modified = last_modified;
615633 }
616634
617- status = this ->LoadLayer (json_layer_object, layer_path, type, last_modified, file_format_version, descriptor);
635+ status = this ->LoadLayer (json_layer_object, layer_path, type, file_format_version, descriptor);
618636 } else {
619637 assert (0 );
620638 }
@@ -623,11 +641,10 @@ LayerLoadStatus LayerManager::LoadLayers(const Path &layer_path, LayerType type,
623641}
624642
625643LayerLoadStatus LayerManager::LoadLayer (const QJsonObject &json_layer_object, const Path &layer_path, LayerType type,
626- const std::string &last_modified, Version file_format_version, LayerDescriptor descriptor) {
644+ Version file_format_version, LayerDescriptor descriptor) {
627645 Layer layer;
628646 layer.type = type;
629647 layer.manifest_path = layer_path;
630- layer.last_modified = last_modified;
631648 layer.file_format_version = file_format_version;
632649 layer.descriptor = descriptor;
633650
@@ -641,7 +658,7 @@ LayerLoadStatus LayerManager::LoadLayer(const QJsonObject &json_layer_object, co
641658 if (duplicated_layer->descriptor .removed ) {
642659 duplicated_layer->descriptor .removed = false ;
643660 duplicated_layer->descriptor .enabled = true ;
644- } else if (duplicated_layer->last_modified != layer.last_modified ) {
661+ } else if (duplicated_layer->descriptor . last_modified != layer. descriptor .last_modified ) {
645662 // Reload when the manifest was updated
646663 LayerLoadStatus reloaded_status = duplicated_layer->Load (json_layer_object);
647664 status = reloaded_status == LAYER_LOAD_ADDED ? LAYER_LOAD_RELOADED : reloaded_status;
0 commit comments