Skip to content

Commit

Permalink
vkconfig3: beta fixes
Browse files Browse the repository at this point in the history
- Fix VK_HOME UI
- Fix rename executable
- Fix clicked event on buttons
- Fix layers paths checking when there are multiple time the same paths
- Fix invalid manifest path that doesn't match the seelcted version
- Fix clear log at launch not saved
- Fix vkconfig layer --list and --list--verbose
- Increased UI log sizes
- Fix keep running on exit
- Fix command line override
- Fix unknown preset value crash
  • Loading branch information
christophe-lunarg committed Nov 27, 2024
1 parent e09b0b6 commit b0bb4f1
Show file tree
Hide file tree
Showing 43 changed files with 305 additions and 163 deletions.
2 changes: 1 addition & 1 deletion vkconfig_cmd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) {

if (vulkan_info.loaderVersion < Version::REQUIRED_LOADER_VERSION) {
fprintf(stderr,
"%s: [ERROR] The system has Vulkan Loader version %s but version %s is requered. Please update the Vulkan Runtime "
"%s: [ERROR] The system has Vulkan Loader version %s but version %s is required. Please update the Vulkan Runtime "
"at https://vulkan.lunarg.com/sdk/home",
VKCONFIG_SHORT_NAME, vulkan_info.loaderVersion.str().c_str(), Version::REQUIRED_LOADER_VERSION.str().c_str());
return -1;
Expand Down
27 changes: 8 additions & 19 deletions vkconfig_cmd/main_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
#include <cassert>

static int RunLayersOverride(Configurator& configurator, const CommandLine& command_line) {
const bool load_result =
configurator.configurations.ImportConfiguration(configurator.layers, command_line.layers_configuration_path);
std::string configuration_name;
const bool load_result = configurator.configurations.ImportConfiguration(
configurator.layers, command_line.layers_configuration_path, configuration_name);
if (!load_result) {
fprintf(stderr, "vkconfig: Failed to load %s layers configuration file...\n",
command_line.layers_configuration_path.c_str());
return -1;
}

configurator.SetActiveConfigurationName(configuration_name);
const bool override_result = configurator.Override(OVERRIDE_AREA_ALL);
if (override_result) {
printf("vkconfig: Layers configuration \"%s\" applied to all Vulkan Applications, including Vulkan layers:\n",
Expand Down Expand Up @@ -78,31 +80,18 @@ static int RunLayersList(Configurator& configurator, const CommandLine& command_
if (configurator.layers.selected_layers.empty()) {
printf("vkconfig: No Vulkan layer found\n");
} else {
for (std::size_t i = 0, n = configurator.layers.selected_layers.size(); i < n; ++i) {
const Layer& layer = configurator.layers.selected_layers[i];
const std::vector<std::string>& layer_names = configurator.layers.GatherLayerNames();

printf("%s\n", layer.key.c_str());
for (std::size_t i = 0, n = layer_names.size(); i < n; ++i) {
printf("%s\n", layer_names[i].c_str());
}
}

return 0;
}

static int RunLayersVerbose(Configurator& configurator, const CommandLine& command_line) {
for (std::size_t i = 0, n = configurator.layers.selected_layers.size(); i < n; ++i) {
const Layer& layer = configurator.layers.selected_layers[i];

printf("%s %s-%s\n", layer.key.c_str(), layer.api_version.str().c_str(), layer.implementation_version.c_str());
printf("- %s\n", layer.description.c_str());
printf("- %s\n", layer.manifest_path.AbsolutePath().c_str());
printf("- %s\n", layer.binary_path.AbsolutePath().c_str());
printf("- %s layer\n", GetToken(layer.type));

if (i < (n - 1)) {
printf("\n");
}
}

printf("%s", configurator.layers.Log().c_str());
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion vkconfig_core/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void Alert::StartLoaderFailure() {
void Alert::StartLoaderIncompatibleVersions(const Version& system_loader_version, const Version& required_loader_version) {
QMessageBox alert;
alert.setWindowTitle("Vulkan Configurator failed to start...");
alert.setText(format("The system has Vulkan Loader version % s but version %s is requered. Please update the Vulkan Runtime.",
alert.setText(format("The system has Vulkan Loader version % s but version %s is required. Please update the Vulkan Runtime.",
system_loader_version.str().c_str(), required_loader_version.str().c_str())
.c_str());
alert.setInformativeText("<a href=\"https://vulkan.lunarg.com/sdk/home\">https://vulkan.lunarg.com/sdk/home</a>");
Expand Down
17 changes: 12 additions & 5 deletions vkconfig_core/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,18 @@ bool Configuration::Load(const Path& full_path, const LayerManager& layers) {
parameter.type = layer->type;
}

if (json_layer_object.value("manifest") != QJsonValue::Undefined) {
std::string manifest_path = ReadString(json_layer_object, "manifest");
if (layers.FindFromManifest(manifest_path) != nullptr) {
parameter.manifest = manifest_path;
if (parameter.api_version != Version::LATEST) {
if (json_layer_object.value("manifest") != QJsonValue::Undefined) {
std::string manifest_path = ReadString(json_layer_object, "manifest");

const Layer* layer = layers.FindFromManifest(manifest_path);
if (layer != nullptr) {
parameter.manifest = manifest_path;
parameter.api_version = layer->api_version;
}
}
} else if (layer != nullptr) {
parameter.manifest = layer->manifest_path;
}

const QJsonValue& json_platform_value = json_layer_object.value("platforms");
Expand Down Expand Up @@ -224,7 +231,7 @@ bool Configuration::Load(const Path& full_path, const LayerManager& layers) {
return true;
}

bool Configuration::Save(const Path& full_path, bool exporter) const {
bool Configuration::Save(const Path& full_path) const {
assert(!full_path.Empty());

QJsonObject root;
Expand Down
2 changes: 1 addition & 1 deletion vkconfig_core/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Configuration {
static Configuration Create(const LayerManager& layers, const std::string& configuration_key);

bool Load(const Path& full_path, const LayerManager& layers);
bool Save(const Path& full_path, bool exporter = false) const;
bool Save(const Path& full_path) const;
void Reset(const LayerManager& layers);

Parameter* Find(const std::string& layer_key);
Expand Down
20 changes: 7 additions & 13 deletions vkconfig_core/configuration_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ void ConfigurationManager::SortConfigurations() {
std::sort(this->available_configurations.begin(), this->available_configurations.end(), Compare());
}

std::vector<ReferencedLayer> ConfigurationManager::BuildReferencedLayers(const LayerManager &layers, const Path &path) {
std::vector<ReferencedLayer> result;

layers.GatherLayerNames();

return result;
}

void ConfigurationManager::LoadConfigurationsPath(const LayerManager &layers) {
const std::vector<Path> &configuration_files = CollectFilePaths(Get(Path::CONFIGS));
for (std::size_t i = 0, n = configuration_files.size(); i < n; ++i) {
Expand Down Expand Up @@ -350,7 +342,8 @@ void ConfigurationManager::RenameConfiguration(const std::string &old_configurat
this->SortConfigurations();
}

bool ConfigurationManager::ImportConfiguration(const LayerManager &layers, const Path &full_import_path) {
bool ConfigurationManager::ImportConfiguration(const LayerManager &layers, const Path &full_import_path,
std::string &configuration_name) {
assert(!full_import_path.Empty());

this->last_path_import_config = full_import_path.AbsoluteDir();
Expand All @@ -360,17 +353,18 @@ bool ConfigurationManager::ImportConfiguration(const LayerManager &layers, const
return false;
}

configuration.key = MakeConfigurationName(this->available_configurations, configuration.key + " (Imported)");
configuration_name = configuration.key =
MakeConfigurationName(this->available_configurations, configuration.key + " (Imported)");
this->available_configurations.push_back(configuration);
this->SortConfigurations();

// this->GetActiveConfigurationInfo()->name = configuration.key;

return true;
}

bool ConfigurationManager::ExportConfiguration(const LayerManager &layers, const Path &full_export_path,
const std::string &configuration_name) {
(void)layers;

assert(!configuration_name.empty());
assert(!full_export_path.Empty());

Expand All @@ -379,5 +373,5 @@ bool ConfigurationManager::ExportConfiguration(const LayerManager &layers, const
Configuration *configuration = this->FindConfiguration(configuration_name);
assert(configuration);

return configuration->Save(full_export_path, true);
return configuration->Save(full_export_path);
}
4 changes: 1 addition & 3 deletions vkconfig_core/configuration_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ConfigurationManager : public Serialize {
int GetConfigurationIndex(const std::string& configuration_name) const;

void RenameConfiguration(const std::string& old_configuration_name, const std::string& new_configuration_name);
bool ImportConfiguration(const LayerManager& layers, const Path& full_import_path);
bool ImportConfiguration(const LayerManager& layers, const Path& full_import_path, std::string& configuration_name);
bool ExportConfiguration(const LayerManager& layers, const Path& full_export_path, const std::string& configuration_name);

const Configuration* FindConfiguration(const std::string& configuration_name) const;
Expand All @@ -62,8 +62,6 @@ class ConfigurationManager : public Serialize {
bool IsDefaultConfiguration(const std::string& configuration_key) const;
void ResetDefaultConfigurations(const LayerManager& layers);

std::vector<ReferencedLayer> BuildReferencedLayers(const LayerManager& layers, const Path& path);

bool Empty() const { return this->available_configurations.empty(); }

bool HasFile(const Configuration& configuration) const;
Expand Down
20 changes: 8 additions & 12 deletions vkconfig_core/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool Configurator::Init(Mode mode) {
QString init_data;

QFile file(vkconfig_init_path.AbsolutePath().c_str());
const bool has_init_file = this->mode == GUI ? file.open(QIODevice::ReadOnly | QIODevice::Text) : false;
const bool has_init_file = file.open(QIODevice::ReadOnly | QIODevice::Text);

if (has_init_file) {
init_data = file.readAll();
Expand Down Expand Up @@ -183,7 +183,7 @@ void Configurator::BuildLoaderSettings(const std::string& configuration_key, con
loader_layer_settings.control = parameter.control;

if (parameter.builtin == LAYER_BUILTIN_NONE) {
const Layer* layer = this->layers.Find(parameter.key, parameter.api_version);
const Layer* layer = this->layers.FindFromManifest(parameter.manifest);
if (layer == nullptr) {
continue;
}
Expand Down Expand Up @@ -446,7 +446,6 @@ bool Configurator::Override(OverrideArea override_area) {
// vk_loader_settings.json
bool result_loader_settings = this->WriteLoaderSettings(override_area, loader_settings_path);

// TODO, Add per application layer_settings file
// vk_layer_settings.txt
bool result_layers_settings = this->WriteLayersSettings(override_area, layers_settings_path);

Expand Down Expand Up @@ -657,7 +656,7 @@ std::string Configurator::Log() const {
}

log += format(" - Use system tray: %s\n", this->use_system_tray ? "true" : "false");
log += format(" - ${VK_HOME}: %s\n", this->home_sdk_path.AbsolutePath().c_str());
log += format(" - ${VK_HOME}: %s\n", ::Get(Path::HOME).AbsolutePath().c_str());
log += "\n";

if (this->GetExecutableScope() == EXECUTABLE_ANY || this->GetExecutableScope() == EXECUTABLE_ALL) {
Expand Down Expand Up @@ -826,9 +825,8 @@ bool Configurator::Load(const QJsonObject& json_root_object) {
if (json_interface_object.value(GetToken(TAB_DIAGNOSTIC)) != QJsonValue::Undefined) {
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_DIAGNOSTIC)).toObject();

this->home_sdk_path = json_object.value("VK_HOME").toString().toStdString();
if (this->home_sdk_path.Empty()) {
this->home_sdk_path = ::Get(Path::HOME);
if (json_object.value("VK_HOME") != QJsonValue::Undefined) {
::SetHomePath(json_object.value("VK_HOME").toString().toStdString());
}
}

Expand Down Expand Up @@ -865,7 +863,7 @@ bool Configurator::Save(QJsonObject& json_root_object) const {
// TAB_DIAGNOSTIC
{
QJsonObject json_object;
json_object.insert("VK_HOME", this->home_sdk_path.RelativePath().c_str());
json_object.insert("VK_HOME", ::Get(Path::HOME).RelativePath().c_str());
json_interface_object.insert(GetToken(TAB_DIAGNOSTIC), json_object);
}

Expand Down Expand Up @@ -907,10 +905,6 @@ bool Configurator::GetUseSystemTray() const { return this->use_system_tray; }

void Configurator::SetUseSystemTray(bool enabled) { this->use_system_tray = enabled; }

Path Configurator::GetHomeSDK() const { return this->home_sdk_path; }

void Configurator::SetHomeSDK(const Path& path) { this->home_sdk_path = path; }

bool Configurator::HasActiveSettings() const {
if (this->executable_scope == EXECUTABLE_NONE) {
return false;
Expand Down Expand Up @@ -972,6 +966,8 @@ std::string Configurator::GenerateVulkanStatus() const {
std::string log;

log += this->Log();

log += "Vulkan Layers Locations\n";
log += this->layers.Log();
log += this->configurations.Log();
log += this->executables.Log();
Expand Down
4 changes: 0 additions & 4 deletions vkconfig_core/configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ class Configurator : public Serialize {
bool GetUseSystemTray() const;
void SetUseSystemTray(bool enabled);

Path GetHomeSDK() const;
void SetHomeSDK(const Path& path);

bool HasActiveSettings() const;
bool HasEnabledUI(EnabledUI enabled_ui) const;

Expand Down Expand Up @@ -139,7 +136,6 @@ class Configurator : public Serialize {
Path last_path_status = ::Get(Path::HOME) + "/vkconfig.txt";

private:
Path home_sdk_path = ::Get(Path::HOME);
int hide_message_boxes_flags = 0;
bool use_system_tray = false;
ExecutableScope executable_scope = EXECUTABLE_ANY;
Expand Down
17 changes: 17 additions & 0 deletions vkconfig_core/executable_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ bool ExecutableManager::Load(const QJsonObject& json_root_object) {
this->last_path_executable = json_executables_object.value("last_path_executable").toString().toStdString();
}

if (json_executables_object.value("clear_on_launch") != QJsonValue::Undefined) {
this->launcher_clear_on_launch = json_executables_object.value("clear_on_launch").toBool();
}

const QJsonObject& json_list_object = json_executables_object.value("list").toObject();

const QStringList& json_list_keys = json_list_object.keys();
Expand Down Expand Up @@ -130,6 +134,7 @@ bool ExecutableManager::Save(QJsonObject& json_root_object) const {
QJsonObject json_executables_object;
json_executables_object.insert("active_executable", this->active_executable.RelativePath().c_str());
json_executables_object.insert("last_path_executable", this->last_path_executable.RelativePath().c_str());
json_executables_object.insert("clear_on_launch", this->launcher_clear_on_launch);

QJsonObject json_executables_list_object;
for (std::size_t i = 0, n = this->data.size(); i < n; ++i) {
Expand Down Expand Up @@ -242,6 +247,18 @@ bool ExecutableManager::RemoveExecutable() {
return true;
}

bool ExecutableManager::RenameActiveExecutable(const Path& executable_path) {
if (this->GetActiveExecutable() == nullptr) {
return false;
}

this->GetActiveExecutable()->path = executable_path;
this->last_path_executable = executable_path;
this->active_executable = executable_path;

return true;
}

bool ExecutableManager::UpdateConfigurations(std::vector<Path>& updated_executable_paths) {
int result = 0;

Expand Down
1 change: 1 addition & 0 deletions vkconfig_core/executable_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ExecutableManager : public Serialize {
bool AppendExecutable(const Executable& executable);
bool AppendExecutable(const Path& executable_path);
bool RemoveExecutable();
bool RenameActiveExecutable(const Path& executable_path);
bool UpdateConfigurations(std::vector<Path>& updated_executable_paths);

const std::vector<Executable>& GetExecutables() const { return this->data; }
Expand Down
4 changes: 3 additions & 1 deletion vkconfig_core/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ LayerControl Layer::GetActualControl() const {
std::string Layer::GetActualControlTooltip() const {
if (this->type == LAYER_TYPE_IMPLICIT) {
if (!this->disable_env.empty()) {
const std::string& value = qgetenv(this->disable_env.c_str()).toStdString();
if (qEnvironmentVariableIsSet(this->disable_env.c_str())) {
return format("'%s' is set", this->disable_env.c_str());
}
Expand Down Expand Up @@ -469,6 +468,9 @@ void Layer::AddSettingData(SettingDataSet& settings_data, const QJsonValue& json
const std::string& key = ReadStringValue(json_setting_object, "key");

SettingMeta* setting_meta = FindSetting(this->settings, key.c_str());
if (setting_meta == nullptr) {
return;
}
assert(setting_meta);

SettingData* setting_data = setting_meta->Instantiate();
Expand Down
Loading

0 comments on commit b0bb4f1

Please sign in to comment.