Skip to content

Commit

Permalink
vkconfig3: Implement diagnostic tab and update documentation tab
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Nov 7, 2024
1 parent dbd97bd commit 799a9eb
Show file tree
Hide file tree
Showing 22 changed files with 342 additions and 424 deletions.
2 changes: 1 addition & 1 deletion vkconfig_core/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void Configuration::GatherParameters(const LayerManager& layers) {
gathered_parameters.push_back(parameter);
}

const std::vector<std::string>& list = layers.BuildLayerNameList();
const std::vector<std::string>& list = layers.GatherLayerNames();

for (std::size_t i = 0, n = list.size(); i < n; ++i) {
const Layer* layer = layers.Find(list[i], Version::LATEST);
Expand Down
2 changes: 1 addition & 1 deletion vkconfig_core/configuration_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void ConfigurationManager::SortConfigurations() {
std::vector<ReferencedLayer> ConfigurationManager::BuildReferencedLayers(const LayerManager &layers, const Path &path) {
std::vector<ReferencedLayer> result;

layers.BuildLayerNameList();
layers.GatherLayerNames();

return result;
}
Expand Down
171 changes: 111 additions & 60 deletions vkconfig_core/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "configurator.h"
#include "registry.h"
#include "vulkan_info.h"
#include "util.h"
#include "path.h"
#include "alert.h"
Expand Down Expand Up @@ -471,7 +470,7 @@ bool Configurator::Surrender(OverrideArea override_area) {
}

#if VKC_ENV == VKC_ENV_WIN32
RemoveRegistryEntriesForLayers(loader_settings_path.AbsolutePath().c_str(), layers_settings_path.AbsolutePath().c_str());
RemoveRegistryEntriesForLayers();
#endif

return result_loader_settings && result_layers_settings;
Expand Down Expand Up @@ -602,16 +601,122 @@ void Configurator::Reset() {
std::string Configurator::Log() const {
std::string log;

log += format("## %s %s - %s\n", VKCONFIG_NAME, Version::VKCONFIG.str().c_str(), GetBuildDate().c_str());

#ifdef _DEBUG
std::string build = "Debug";
#else
std::string build = "Release";
#endif

log += format("- Build: %s %s\n", GetLabel(VKC_PLATFORM), build.c_str());
log += format("- Vulkan API version: %s\n", Version::VKHEADER.str().c_str());
log += format("%s %s - %s:\n", VKCONFIG_NAME, Version::VKCONFIG.str().c_str(), GetBuildDate().c_str());
log += format(" - Build: %s %s\n", GetLabel(VKC_PLATFORM), build.c_str());
log += format(" - Vulkan API version: %s\n", Version::VKHEADER.str().c_str());
log += format(" - ${VULKAN_SDK}: %s\n", ::Get(Path::SDK).AbsolutePath().c_str());
log += "\n";

log += format("%s Settings:\n", VKCONFIG_NAME);
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(" - Vulkan Loader and Layers system files:\n");
log += format(" * %s\n", ::Get(Path::LOADER_SETTINGS).AbsolutePath().c_str());
log += format(" * %s\n", ::Get(Path::LAYERS_SETTINGS).AbsolutePath().c_str());
log += "\n";

log += "Vulkan Physical Devices:\n";
for (std::size_t i = 0, n = this->vulkan_system_info.physicalDevices.size(); i < n; ++i) {
const VulkanPhysicalDeviceInfo& info = this->vulkan_system_info.physicalDevices[i];
log += format(" - %s with Vulkan %s (%s)\n", info.deviceName.c_str(), info.apiVersion.str().c_str(),
GetLabel(info.deviceType));
if (info.vendorID == 0x10DE) {
log += format(" * Driver: %s %s\n", GetLabel(info.vendorID).c_str(), FormatNvidia(info.driverVersion).c_str());
} else if ((info.vendorID == 0x8086) && (VKC_PLATFORM & PLATFORM_WINDOWS_BIT)) {
log += format(" * Driver: %s %s\n", GetLabel(info.vendorID).c_str(), FormatIntelWindows(info.driverVersion).c_str());
} else {
log += format(" * Driver: %s %s\n", GetLabel(info.vendorID).c_str(), Version(info.driverVersion).str().c_str());
}
log += format(" * deviceUUID: %s\n", info.deviceUUID.c_str());
log += format(" * driverUUID: %s\n", info.driverUUID.c_str());
log += format(" * deviceLUID: %s\n", info.deviceLUID.c_str());
}
log += "\n";

log += "Vulkan Loader Settings:\n";
if (this->vulkan_system_info.loaderVersion != Version::NONE) {
log += format(" - API version: %s\n", this->vulkan_system_info.loaderVersion.str().c_str());
} else {
log += format(" - Couldn't Find a Vulkan Loader\n");
}

log += " - Vulkan Loader found Vulkan layers:\n";
for (std::size_t i = 0, n = this->vulkan_system_info.instanceLayerProperties.size(); i < n; ++i) {
log += format(" * %s\n", this->vulkan_system_info.instanceLayerProperties[i].layerName);
}
log += " - Vulkan implementation or by implicitly enabled layers extensions:\n";
for (std::size_t i = 0, n = this->vulkan_system_info.instanceExtensionPropertie.size(); i < n; ++i) {
log += format(" * %s\n", this->vulkan_system_info.instanceExtensionPropertie[i].extensionName);
}

if (qEnvironmentVariableIsSet("VK_LOADER_DISABLE_DYNAMIC_LIBRARY_UNLOADING")) {
log += format(" - ${VK_LOADER_DISABLE_DYNAMIC_LIBRARY_UNLOADING}: %s\n",
qgetenv("VK_LOADER_DISABLE_DYNAMIC_LIBRARY_UNLOADING").toStdString().c_str());
} else {
log += " - ${VK_LOADER_DISABLE_DYNAMIC_LIBRARY_UNLOADING}: unset\n";
}

log += " - Vulkan Loader Layers environment variables:\n";
if (qEnvironmentVariableIsSet("VK_LOADER_DEBUG")) {
log += format(" * ${VK_LOADER_DEBUG}: %s\n", qgetenv("VK_LOADER_DEBUG").toStdString().c_str());
} else {
log += " * ${VK_LOADER_DEBUG}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_LOADER_LAYERS_ENABLE")) {
log += format(" * ${VK_LOADER_LAYERS_ENABLE}: %s\n", qgetenv("VK_LOADER_LAYERS_ENABLE").toStdString().c_str());
} else {
log += " * ${VK_LOADER_LAYERS_ENABLE}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_LOADER_LAYERS_DISABLE")) {
log += format(" * ${VK_LOADER_LAYERS_DISABLE}: %s\n", qgetenv("VK_LOADER_LAYERS_DISABLE").toStdString().c_str());
} else {
log += " * ${VK_LOADER_LAYERS_DISABLE}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_LOADER_LAYERS_ALLOW")) {
log += format(" * ${VK_LOADER_LAYERS_ALLOW}: %s\n", qgetenv("VK_LOADER_LAYERS_ALLOW").toStdString().c_str());
} else {
log += " * ${VK_LOADER_LAYERS_ALLOW}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_INSTANCE_LAYERS")) {
log += format(" * ${VK_INSTANCE_LAYERS}: %s\n", qgetenv("VK_INSTANCE_LAYERS").toStdString().c_str());
}
log += " - Vulkan Loader Drivers environment variables:\n";
if (qEnvironmentVariableIsSet("VK_DRIVER_FILES")) {
log += format(" * ${VK_DRIVER_FILES}: %s\n", qgetenv("VK_DRIVER_FILES").toStdString().c_str());
} else {
log += " * ${VK_DRIVER_FILES}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_ADD_DRIVER_FILES")) {
log += format(" * ${VK_ADD_DRIVER_FILES}: %s\n", qgetenv("VK_ADD_DRIVER_FILES").toStdString().c_str());
} else {
log += " * ${VK_ADD_DRIVER_FILES}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_LOADER_DRIVERS_SELECT")) {
log += format(" * ${VK_LOADER_DRIVERS_SELECT}: %s\n", qgetenv("VK_LOADER_DRIVERS_SELECT").toStdString().c_str());
} else {
log += " * ${VK_LOADER_DRIVERS_SELECT}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_LOADER_DRIVERS_DISABLE")) {
log += format(" * ${VK_LOADER_DRIVERS_DISABLE}: %s\n", qgetenv("VK_LOADER_DRIVERS_DISABLE").toStdString().c_str());
} else {
log += " * ${VK_LOADER_DRIVERS_DISABLE}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_LOADER_DISABLE_INST_EXT_FILTER")) {
log += format(" * ${VK_LOADER_DISABLE_INST_EXT_FILTER}: %s\n",
qgetenv("VK_LOADER_DISABLE_INST_EXT_FILTER").toStdString().c_str());
} else {
log += " * ${VK_LOADER_DISABLE_INST_EXT_FILTER}: unset\n";
}
if (qEnvironmentVariableIsSet("VK_ICD_FILENAMES")) {
log += format(" * ${VK_ICD_FILENAMES}: %s\n", qgetenv("VK_ICD_FILENAMES").toStdString().c_str());
}
log += "\n";

return log;
}
Expand Down Expand Up @@ -800,60 +905,6 @@ std::string Configurator::GenerateVulkanStatus() const {
log += "- Environment variables:\n";
// Check Vulkan SDK path
if (Get(Path::SDK).Empty())
log += " - ${VULKAN_SDK} not set\n";
else
log += format(" - ${VULKAN_SDK}: %s\n", AbsolutePath(Path::SDK).c_str());
// Check VK_HOME path
if (!Get(Path::HOME).Empty()) {
log += format(" - ${VK_HOME}: %s\n", AbsolutePath(Path::HOME).c_str());
}
const Version loader_version = GetVulkanLoaderVersion();
if (loader_version == Version::VERSION_NULL) {
Alert::LoaderFailure();
log += "- Could not find a Vulkan Loader.\n";
return log;
} else {
log += format("- Vulkan Loader version: %s\n", loader_version.str().c_str());
const LogFlags log_flags = configurator.environment.GetLoaderMessageFlags();
if (log_flags != 0) {
log += format(" - ${VK_LOADER_DEBUG}=%s\n", GetLogString(log_flags).c_str());
}
}
log += "- User-Defined Layers locations:\n";
log += GetUserDefinedLayersPathsLog("${VK_LAYER_PATH} variable", USER_DEFINED_LAYERS_PATHS_ENV_SET);
log += GetUserDefinedLayersPathsLog("Per-configuration paths", USER_DEFINED_LAYERS_PATHS_GUI);
log += GetUserDefinedLayersPathsLog("${VK_ADD_LAYER_PATH} variable", USER_DEFINED_LAYERS_PATHS_ENV_ADD);
// vk_layer_settings.txt
const Path layer_settings_path(qgetenv("VK_LAYER_SETTINGS_PATH").toStdString());
if (!layer_settings_path.Empty()) {
log += "- `vk_layer_settings.txt` location overridden by VK_LAYER_SETTINGS_PATH:\n";
if (layer_settings_path.RelativePath().find("vk_layer_settings.txt") == std::string::npos) {
log += format(" %s\n", layer_settings_path.RelativePath().c_str());
} else {
log += format(" %s\n", layer_settings_path.AbsoluteDir().c_str());
}
} else {
log += "- `vk_layer_settings.txt` uses the default platform path:\n";
log += format(" %s\n", AbsolutePath(Path::LAYERS_SETTINGS).c_str());
}
// vk_loader_settings.json
log += "- `vk_loader_settings.json` uses the default platform path:\n";
log += format(" %s\n", AbsolutePath(Path::LOADER_SETTINGS).c_str());
// If there is no Vulkan loader installed, we can't call any Vulkan API.
if (loader_version == Version::VERSION_NULL) {
return log;
}
LayersMode saved_mode = configurator.environment.GetMode();
configurator.environment.SetMode(LAYERS_CONTROLLED_BY_APPLICATIONS);
configurator.Configure(configurator.layers.selected_layers);
Expand Down
2 changes: 1 addition & 1 deletion vkconfig_core/configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#pragma once

#include "version.h"
#include "vulkan_util.h"
#include "configuration_manager.h"
#include "configuration_manager.h"
#include "layer_manager.h"
Expand All @@ -31,7 +32,6 @@
#include "type_hide_message.h"
#include "type_tab.h"
#include "type_executable_mode.h"
#include "vulkan_info.h"
#include "serialization.h"

class Configurator : public Serialize {
Expand Down
4 changes: 2 additions & 2 deletions vkconfig_core/layer.h
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-2024 Valve Corporation
* Copyright (c) 2020-2024 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
98 changes: 75 additions & 23 deletions vkconfig_core/layer_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@

#include <QJsonArray>

std::vector<LayersPathInfo> GetEnvVariablePaths(const char *variable_name, LayerType type) {
std::vector<LayersPathInfo> result;

const char *SEPARATOR = GetToken(PARSE_ENV_VAR);

const std::vector<std::string> &paths = UniqueStrings(Split(qgetenv(variable_name).toStdString(), SEPARATOR));
result.resize(paths.size());
for (std::size_t i = 0, n = paths.size(); i < n; ++i) {
result[i].path = paths[i];
result[i].enabled = true;
result[i].type = type;
}

return result;
}

std::vector<LayersPathInfo> GetImplicitLayerPaths() {
std::vector<LayersPathInfo> result;

Expand Down Expand Up @@ -203,39 +219,59 @@ void LayerManager::Reset() {

std::string LayerManager::Log() const {
std::string log;

log += "Vulkan Layers Locations\n";

for (std::size_t group_index = 0, group_count = this->paths.size(); group_index < group_count; ++group_index) {
const std::vector<LayersPathInfo> &paths_group = this->paths[group_index];
if (paths_group.empty()) {
log += format(" %d. %s paths:\n", group_index + 1, ::GetLabel(static_cast<LayersPaths>(group_index)));
log += format(" - None\n");
} else {
log += format(" %d. %s paths:\n", group_index + 1, ::GetLabel(static_cast<LayersPaths>(group_index)));
}

for (std::size_t path_index = 0, path_count = paths_group.size(); path_index < path_count; ++path_index) {
log += format(" - %s (%s)\n", paths_group[path_index].path.AbsolutePath().c_str(),
paths_group[path_index].enabled ? "enabled" : "disabled");

const std::vector<const Layer *> layers = this->GatherLayers(paths_group[path_index]);

for (std::size_t i = 0, n = layers.size(); i < n; ++i) {
log += format(" * %s - %s", layers[i]->key.c_str(), layers[i]->api_version.str().c_str());
if (layers[i]->status != STATUS_STABLE) {
log += format(" (%s)", GetToken(layers[i]->status));
}
log += "\n";
}
}
}

log += "\n";

return log;
}

void LayerManager::InitSystemPaths() {
this->selected_layers.clear();
this->layers_validated.clear();

this->paths[LAYERS_PATHS_IMPLICIT] = GetImplicitLayerPaths();
this->paths[LAYERS_PATHS_IMPLICIT_SYSTEM] = GetImplicitLayerPaths();

this->paths[LAYERS_PATHS_EXPLICIT] = GetExplicitLayerPaths();
// LAYERS_PATHS_IMPLICIT_ENV_SET: VK_IMPLICIT_LAYER_PATH env variables
this->paths[LAYERS_PATHS_IMPLICIT_ENV_SET] = GetEnvVariablePaths("VK_IMPLICIT_LAYER_PATH", LAYER_TYPE_IMPLICIT);

const char *SEPARATOR = GetToken(PARSE_ENV_VAR);
// LAYERS_PATHS_IMPLICIT_ENV_ADD: VK_ADD_IMPLICIT_LAYER_PATH env variables
this->paths[LAYERS_PATHS_IMPLICIT_ENV_ADD] = GetEnvVariablePaths("VK_ADD_IMPLICIT_LAYER_PATH", LAYER_TYPE_IMPLICIT);

// LAYERS_PATHS_ENV_SET: VK_LAYER_PATH env variables
{
const std::vector<std::string> &VK_LAYER_PATH = UniqueStrings(Split(qgetenv("VK_LAYER_PATH").toStdString(), SEPARATOR));
this->paths[LAYERS_PATHS_ENV_SET].resize(VK_LAYER_PATH.size());
for (std::size_t i = 0, n = VK_LAYER_PATH.size(); i < n; ++i) {
this->paths[LAYERS_PATHS_ENV_SET][i].path = VK_LAYER_PATH[i];
this->paths[LAYERS_PATHS_ENV_SET][i].enabled = true;
}
}
// LAYERS_PATHS_EXPLICIT_SYSTEM
this->paths[LAYERS_PATHS_EXPLICIT_SYSTEM] = GetExplicitLayerPaths();

// LAYERS_PATHS_ENV_ADD: VK_ADD_LAYER_PATH env variables
{
const std::vector<std::string> &VK_ADD_LAYER_PATH =
UniqueStrings(Split(qgetenv("VK_ADD_LAYER_PATH").toStdString(), SEPARATOR));
this->paths[LAYERS_PATHS_ENV_ADD].resize(VK_ADD_LAYER_PATH.size());
for (std::size_t i = 0, n = VK_ADD_LAYER_PATH.size(); i < n; ++i) {
this->paths[LAYERS_PATHS_ENV_ADD][i].path = VK_ADD_LAYER_PATH[i];
this->paths[LAYERS_PATHS_ENV_ADD][i].enabled = true;
}
}
// LAYERS_PATHS_EXPLICIT_ENV_SET: VK_LAYER_PATH env variables
this->paths[LAYERS_PATHS_EXPLICIT_ENV_SET] = GetEnvVariablePaths("VK_LAYER_PATH", LAYER_TYPE_EXPLICIT);

// LAYERS_PATHS_EXPLICIT_ENV_ADD: VK_ADD_LAYER_PATH env variables
this->paths[LAYERS_PATHS_EXPLICIT_ENV_ADD] = GetEnvVariablePaths("VK_ADD_LAYER_PATH", LAYER_TYPE_EXPLICIT);

// LAYERS_PATHS_SDK
this->paths[LAYERS_PATHS_SDK].clear();
Expand Down Expand Up @@ -481,7 +517,7 @@ void LayerManager::UpdatePathEnabled(const LayersPathInfo &path_info) {
}
}

std::vector<std::string> LayerManager::BuildLayerNameList() const {
std::vector<std::string> LayerManager::GatherLayerNames() const {
std::vector<std::string> result;

for (std::size_t i = 0, n = this->selected_layers.size(); i < n; ++i) {
Expand All @@ -498,3 +534,19 @@ std::vector<std::string> LayerManager::BuildLayerNameList() const {

return result;
}

std::vector<const Layer *> LayerManager::GatherLayers(const LayersPathInfo &path_info) const {
std::vector<const Layer *> result;

for (std::size_t i = 0, n = this->selected_layers.size(); i < n; ++i) {
const std::string &layer_path = path_info.path.AbsolutePath();
const std::string &current_layer_path = this->selected_layers[i].manifest_path.AbsolutePath();
if (current_layer_path.find(layer_path) == std::string::npos) {
continue;
}

result.push_back(&this->selected_layers[i]);
}

return result;
}
3 changes: 2 additions & 1 deletion vkconfig_core/layer_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class LayerManager : public Serialize {
void RemovePath(const LayersPathInfo& path_info);
void UpdatePathEnabled(const LayersPathInfo& path_info);

std::vector<std::string> BuildLayerNameList() const;
std::vector<std::string> GatherLayerNames() const;
std::vector<const Layer*> GatherLayers(const LayersPathInfo& path_info) const;

std::vector<Layer> selected_layers;
std::array<std::vector<LayersPathInfo>, LAYERS_PATHS_COUNT> paths;
Expand Down
Loading

0 comments on commit 799a9eb

Please sign in to comment.