Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions vkconfig_cmd/main_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,21 @@ static int RunLayersSurrender(Configurator& configurator, const CommandLine& com
}

static int RunLayersPath(Configurator& configurator, const CommandLine& command_line) {
printf("vkconfig: [INFO] Paths to find Vulkan Layers\n");
printf("vkconfig: [INFO] Vulkan Layers paths:\n");

for (int layers_paths_index = 0, layers_paths_count = LAYERS_PATHS_COUNT; layers_paths_index < layers_paths_count;
++layers_paths_index) {
const std::vector<LayersPathInfo>& paths = configurator.layers.paths[layers_paths_index];
printf("\n%s:\n", GetLabel(static_cast<LayersPaths>(layers_paths_index)));
const std::set<LayerDisplay>& layer_display_list = configurator.layers.BuildLayerDisplayList();

if (paths.empty()) {
printf(" - None\n");
} else {
for (std::size_t i = 0, n = paths.size(); i < n; ++i) {
if (paths[i].enabled) {
printf(" - %s\n", paths[i].path.AbsolutePath().c_str());
}
}
for (auto it = layer_display_list.begin(), end = layer_display_list.end(); it != end; ++it) {
const Layer* layer = configurator.layers.FindFromManifest(it->id.manifest_path, true);
if (layer == nullptr) {
continue;
}

const std::string status = layer->status == STATUS_STABLE ? "" : format(" (%s)", ::GetToken(layer->status));
const std::string text = format("%s - %s%s, %s layer", layer->key.c_str(), layer->api_version.str().c_str(), status.c_str(),
::GetToken(layer->type));

printf(" - %s\n", text.c_str());
}

return 0;
Expand Down
4 changes: 2 additions & 2 deletions vkconfig_core/application_singleton.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020-2021 Valve Corporation
* Copyright (c) 2020-2021 LunarG, Inc.
* Copyright (c) 2020-2026 Valve Corporation
* Copyright (c) 2020-2026 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion vkconfig_core/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool Configuration::Load(const Path& full_path, const LayerManager& layers) {

if (layer != nullptr) {
parameter.manifest = layer->manifest_path;
parameter.type = layer->type;
// parameter.type = layer->type;
}

if (parameter.api_version != Version::LATEST) {
Expand Down
5 changes: 0 additions & 5 deletions vkconfig_core/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ class Configuration {
LayerControl default_control = LAYER_CONTROL_AUTO;
bool override_settings = false;
Path override_settings_path;
// bool override_layers = true; // Keep or not ?
std::string selected_layer_name;
// bool override_driver = false;
// std::string override_driver_name = DEFAULT_PHYSICAL_DEVICE;
// bool override_loader = true;
// int loader_log_messages_flags = GetBit(LOG_ERROR);

std::vector<Parameter> parameters;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"file_format_version": "3.0.0",
"configuration": {
"name": "Discard Ordering and Enabling Layers",
"version": 1,
"platforms": [
"WINDOWS",
"LINUX",
"MACOS"
],
"selected_layer_name": "",
"default_layer_control": "discard",
"override_layers": true,
"override_loader": false,
"loader_message_types": [
"error",
"warn",
"info",
"debug",
"perf",
"layer",
"driver"
],
"layers": [
{
"builtin": "unordered_layer_location",
"control": "auto",
"name": "Vulkan Layers Located by Vulkan Applications",
"override_settings": true,
"platforms": [
"WINDOWS_X86",
"WINDOWS_ARM",
"LINUX",
"MACOS"
],
"rank": 9,
"settings": [
],
"type": "Explicit",
"version": "latest"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"file_format_version": "3.0.0",
"configuration": {
"name": "API dump",
"name": "Validation with API Dump Log",
"version": 1,
"platforms": [
"WINDOWS",
Expand Down
147 changes: 132 additions & 15 deletions vkconfig_core/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ QJsonObject Configurator::CreateJsonSettingObject(const Configurator::LoaderSett
json_settings.insert("app_keys", json_app_keys);
}

if (loader_settings.override_layers) {
if (this->layers_override_enabled) {
json_settings.insert("layers", json_layers);
}

Expand Down Expand Up @@ -244,6 +244,14 @@ QJsonObject Configurator::CreateJsonSettingObject(const Configurator::LoaderSett
}
json_settings.insert("device_configurations", json_devices);
} break;
case DRIVER_MODE_NONE: {
QJsonArray json_devices;
json_settings.insert("device_configurations", json_devices);
} break;
default: {
assert(0);
break;
}
}
}

Expand Down Expand Up @@ -316,6 +324,13 @@ QJsonObject Configurator::CreateJsonGlobalObject() const {
}
json_settings.insert("device_configurations", json_devices);
} break;
case DRIVER_MODE_NONE: {
QJsonArray json_devices;
json_settings.insert("device_configurations", json_devices);
} break;
default: {
assert(0);
}
}
}

Expand Down Expand Up @@ -442,7 +457,7 @@ bool Configurator::WriteLoaderSettings(OverrideArea override_area, const Path& l
break;
}
default:
case EXECUTABLE_NONE:
assert(0);
break;
}

Expand Down Expand Up @@ -557,6 +572,7 @@ void Configurator::Reset(bool hard) {
this->Surrender(OVERRIDE_AREA_LOADER_SETTINGS_BIT);

const Path& vkconfig_init_path = ::Path(Path::INIT);
vkconfig_init_path.Backup();
vkconfig_init_path.Remove();

QSettings settings("LunarG", VKCONFIG_SHORT_NAME);
Expand Down Expand Up @@ -1089,15 +1105,52 @@ bool Configurator::Load() {
// TAB_CONFIGURATIONS
if (json_interface_object.value(GetToken(TAB_CONFIGURATIONS)) != QJsonValue::Undefined) {
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_CONFIGURATIONS)).toObject();
if (json_object.value("override_layers") != QJsonValue::Undefined) {
this->layers_override_enabled = json_object.value("override_layers").toBool();
}
this->advanced = json_object.value("advanced").toBool();
this->executable_scope = ::GetExecutableScope(json_object.value("executable_scope").toString().toStdString().c_str());
this->selected_global_configuration = json_object.value("selected_global_configuration").toString().toStdString();
}

// TAB_LAYERS
if (json_interface_object.value(GetToken(TAB_LAYERS)) != QJsonValue::Undefined) {
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_LAYERS)).toObject();
(void)json_object;
// TAB_LAYERS_PATHS
if (json_interface_object.value(GetToken(TAB_LAYERS_PATHS)) != QJsonValue::Undefined) {
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_LAYERS_PATHS)).toObject();
if (json_object.value("last_driver_dir") != QJsonValue::Undefined) {
this->layers.last_layers_dir = json_object.value("last_driver_dir").toString().toStdString();
}
if (json_object.value("validate_manifests") != QJsonValue::Undefined) {
this->layers.validate_manifests = json_object.value("validate_manifests").toBool();
}
if (json_object.value("layers") != QJsonValue::Undefined) {
const QJsonObject& json_object_paths = json_object.value("layers").toObject();
QStringList keys = json_object_paths.keys();
for (std::size_t i = 0, n = keys.size(); i < n; ++i) {
const QJsonArray& json_descriptors = json_object_paths.value(keys[i]).toArray();

std::vector<LayerDisplay> descriptors;
for (std::size_t j = 0, o = json_descriptors.size(); j < o; ++j) {
const QJsonObject& json_descriptor_object = json_descriptors[j].toObject();

LayerDisplay display;
display.id.key = json_descriptor_object.value("key").toString().toStdString();
display.id.manifest_path = keys[i].toStdString();
display.id.api_version = Version::NONE;
display.descriptor.enabled = json_descriptor_object.value("enabled").toBool();
display.descriptor.removed = json_descriptor_object.value("removed").toBool();
display.descriptor.validated = json_descriptor_object.value("validated").toBool();
descriptors.push_back(display);
}

this->layers.AppendInit(Path(keys[i].toStdString()), descriptors);
}
}
if (json_object.value("paths") != QJsonValue::Undefined) {
const QJsonArray& json_paths = json_object.value("paths").toArray();
for (std::size_t i = 0, n = json_paths.size(); i < n; ++i) {
this->layers.gui_added_layers_paths.insert(json_paths[i].toString().toStdString());
}
}
}

// TAB_DRIVERS
Expand Down Expand Up @@ -1141,8 +1194,8 @@ bool Configurator::Load() {
}
}

if (json_object.value("last_driver_path") != QJsonValue::Undefined) {
this->last_driver_path = json_object.value("last_driver_path").toString().toStdString();
if (json_object.value("last_driver_dir") != QJsonValue::Undefined) {
this->last_driver_dir = json_object.value("last_driver_dir").toString().toStdString();
}
if (json_object.value("driver_paths") != QJsonValue::Undefined) {
const QJsonObject& json_object_paths = json_object.value("driver_paths").toObject();
Expand Down Expand Up @@ -1180,6 +1233,10 @@ bool Configurator::Load() {
if (json_interface_object.value(GetToken(TAB_PREFERENCES)) != QJsonValue::Undefined) {
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_PREFERENCES)).toObject();

if (json_object.value("validate_manifests") != QJsonValue::Undefined) {
this->layers.validate_manifests = json_object.value("validate_manifests").toBool();
}

if (json_object.value("use_notify_releases") != QJsonValue::Undefined) {
this->use_notify_releases = json_object.value("use_notify_releases").toBool();
}
Expand Down Expand Up @@ -1224,10 +1281,17 @@ bool Configurator::Load() {
::SetHomePath(json_object.value("VULKAN_HOME").toString().toStdString());
}

if (json_object.value("layers_show_scope") != QJsonValue::Undefined) {
this->configuration_show_scope = json_object.value("layers_show_scope").toBool();
} else {
this->configuration_show_scope = this->executable_scope != EXECUTABLE_ANY;
}

if (json_object.value("all_enabled_executables_behavior") != QJsonValue::Undefined) {
this->executable_behavior = ::GetExecutableAllEnabledBehavior(
json_object.value("all_enabled_executables_behavior").toString().toStdString().c_str());
}

if (json_object.value("VULKAN_DOWNLOAD") != QJsonValue::Undefined) {
::SetDownloadPath(json_object.value("VULKAN_DOWNLOAD").toString().toStdString());
}
Expand Down Expand Up @@ -1277,16 +1341,62 @@ bool Configurator::Save() const {
// TAB_CONFIGURATIONS
{
QJsonObject json_object;
json_object.insert("override_layers", this->layers_override_enabled);
json_object.insert("advanced", this->advanced);
json_object.insert("executable_scope", ::GetToken(this->executable_scope));
json_object.insert("selected_global_configuration", this->selected_global_configuration.c_str());
json_interface_object.insert(::GetToken(TAB_CONFIGURATIONS), json_object);
}

// TAB_LAYERS
// TAB_LAYERS_PATHS
{
std::map<Path, std::map<std::string, LayerDisplay>> data = this->layers.BuildLayerStoreList();

QJsonObject json_layers;
for (auto it = data.begin(); it != data.end(); ++it) {
std::map<std::string, LayerDisplay> descriptors = it->second;

QJsonArray json_layer_descriptors;

bool is_user_added_path =
this->layers.gui_added_layers_paths.find(it->first.AbsoluteDir()) != this->layers.gui_added_layers_paths.end();

bool keep = false; // Only remember paths that don't have all layer removed

for (auto jt = it->second.begin(); jt != it->second.end(); ++jt) {
if (!jt->second.descriptor.removed) {
keep = true;
}

QJsonObject json_descriptor;
json_descriptor.insert("key", jt->first.c_str());
json_descriptor.insert("validated", jt->second.descriptor.validated);
json_descriptor.insert("enabled", jt->second.descriptor.enabled);
json_descriptor.insert("removed", jt->second.descriptor.removed);

json_layer_descriptors.append(json_descriptor);
}

if (is_user_added_path) {
if (keep) {
json_layers.insert(it->first.AbsolutePath().c_str(), json_layer_descriptors);
}
} else {
json_layers.insert(it->first.AbsolutePath().c_str(), json_layer_descriptors);
}
}

QJsonArray json_paths;
for (auto it = this->layers.gui_added_layers_paths.begin(); it != this->layers.gui_added_layers_paths.end(); ++it) {
json_paths.append(it->AbsolutePath().c_str());
}

QJsonObject json_object;
json_interface_object.insert(GetToken(TAB_LAYERS), json_object);
json_object.insert("paths", json_paths);
json_object.insert("layers", json_layers);
json_object.insert("validate_manifests", this->layers.validate_manifests);
json_object.insert("last_driver_dir", this->layers.last_layers_dir.AbsolutePath().c_str());
json_interface_object.insert(::GetToken(TAB_LAYERS_PATHS), json_object);
}

// TAB_DRIVER
Expand Down Expand Up @@ -1325,7 +1435,7 @@ bool Configurator::Save() const {
}
json_object.insert("driver_override_list", json_driver_override_list_array);

json_object.insert("last_driver_path", this->last_driver_path.RelativePath().c_str());
json_object.insert("last_driver_dir", this->last_driver_dir.RelativePath().c_str());
QJsonObject json_object_paths;
for (auto it = this->driver_paths.begin(); it != this->driver_paths.end(); ++it) {
QJsonObject json_object_path;
Expand Down Expand Up @@ -1368,6 +1478,7 @@ bool Configurator::Save() const {
json_object.insert("show_external_layers_settings", this->show_external_layers_settings);
json_object.insert("VULKAN_HOME", ::Path(Path::HOME).RelativePath().c_str());
json_object.insert("VULKAN_DOWNLOAD", ::Path(Path::DOWNLOAD).RelativePath().c_str());
json_object.insert("layers_show_scope", this->configuration_show_scope);
json_object.insert("all_enabled_executables_behavior", ::GetToken(this->executable_behavior));

json_interface_object.insert(GetToken(TAB_PREFERENCES), json_object);
Expand Down Expand Up @@ -1449,9 +1560,13 @@ bool Configurator::ShouldNotify() const {
}

bool Configurator::HasActiveSettings() const {
if (!this->layers_override_enabled) {
return false;
}

switch (this->executable_scope) {
default:
case EXECUTABLE_NONE:
assert(0);
return false;
case EXECUTABLE_ALL:
case EXECUTABLE_PER:
Expand Down Expand Up @@ -1483,18 +1598,20 @@ bool Configurator::HasActiveSettings() const {
}

bool Configurator::HasEnabledUI(EnabledUI enabled_ui) const {
if (!this->layers_override_enabled) {
return false;
}

switch (enabled_ui) {
default:
assert(false);
return false;
case ENABLE_UI_CONFIG: {
switch (this->GetExecutableScope()) {
default:
case EXECUTABLE_NONE:
return false;
case EXECUTABLE_ALL:
case EXECUTABLE_PER:
return this->executables.GetActiveExecutable() != nullptr;
default:
case EXECUTABLE_ANY:
return true;
}
Expand Down
Loading
Loading