Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vkconfig3: beta bugfixing #2205

Merged
merged 1 commit into from
Nov 28, 2024
Merged
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
2 changes: 1 addition & 1 deletion vkconfig_core/configurations/3.0.0/Portability.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{
"key": "profile_dirs",
"type": "LOAD_FOLDER",
"value": "${VULKAN_CONTENT}/VK_LAYER_KHRONOS_profiles"
"value": "${VULKAN_PROFILES}"
},
{
"key": "profile_name",
Expand Down
8 changes: 7 additions & 1 deletion vkconfig_core/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,11 @@ std::string Configurator::Log() const {
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());
if (::Get(Path::SDK).Empty()) {
log += " - ${VULKAN_SDK}: unset\n";
} else {
log += format(" - ${VULKAN_SDK}: %s\n", ::Get(Path::SDK).AbsolutePath().c_str());
}
log += "\n";

log += format("%s Settings:\n", VKCONFIG_NAME);
Expand Down Expand Up @@ -620,6 +624,8 @@ std::string Configurator::Log() const {
}

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

Expand Down
2 changes: 1 addition & 1 deletion vkconfig_core/executable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ DefaultPath GetDefaultExecutablePath(const std::string& executable_key) {
DefaultPath default_path{"." + executable_name, "."};

// Using VULKAN_SDK environement variable
const Path env = ::Get(Path::SDK_BIN);
const Path env = ::Get(Path::BIN);
if (!env.Empty()) {
const Path search_path(env + DEFAULT_PATH + executable_name.c_str());
if (search_path.Exists()) {
Expand Down
10 changes: 8 additions & 2 deletions vkconfig_core/executable_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ const char* GetExecutableFilter() {
}

static const DefaultExecutable defaults_executables[] = {
{"vkcube", "/vkcube", "--suppress_popups", "VkCube launcher options"},
{"vkcubepp", "/vkcubepp", "--suppress_popups", "VkCubepp launcher options"}};
{"vkcube", "/vkcube", "--suppress_popups", "vkcube launcher options"},
{"vkcubepp", "/vkcubepp", "--suppress_popups", "vkcubepp launcher options"},
#if VKC_ENV == VKC_ENV_WIN32
{"vulkaninfoSDK", "/vulkaninfoSDK", "--json", "vulkaninfo launcher options"},
#else
{"vulkaninfo", "/vulkaninfo", "--json", "vulkaninfo launcher options"},
#endif
};

std::string ExecutableManager::Log() const {
std::string log;
Expand Down
82 changes: 59 additions & 23 deletions vkconfig_core/layer_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,42 @@ std::vector<LayersPathInfo> GetImplicitLayerPaths() {
LoadRegistrySystemLayers("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Class\\...\\VulkanImplicitLayers");
result.insert(result.begin(), drivers_registry_paths.begin(), drivers_registry_paths.end());
#else
static const char *LAYERS_PATHS[] = {
"/usr/local/etc/vulkan/implicit_layer.d", // Not used on macOS, okay to just ignore
"/usr/local/share/vulkan/implicit_layer.d",
"/etc/vulkan/implicit_layer.d",
"/usr/share/vulkan/implicit_layer.d",
".local/share/vulkan/implicit_layer.d",
std::vector<std::string> paths;
if (VKC_PLATFORM == PLATFORM_MACOS) {
static const char *LAYERS_PATHS[] = {
"/usr/local/share/vulkan/implicit_layer.d",
".local/share/vulkan/implicit_layer.d",
};

for (std::size_t i = 0, n = std::size(LAYERS_PATHS); i < n; ++i) {
paths.push_back(LAYERS_PATHS[i]);
}
} else {
static const char *LAYERS_PATHS[] = {
"/usr/local/etc/vulkan/implicit_layer.d",
"/usr/local/share/vulkan/implicit_layer.d",
"/etc/vulkan/implicit_layer.d",
"/usr/share/vulkan/implicit_layer.d",
".local/share/vulkan/implicit_layer.d",
#ifdef _DEBUG
#ifdef INSTALL_FULL_DATAROOTDIR
INSTALL_FULL_DATAROOTDIR "/vulkan/implicit_layer.d",
INSTALL_FULL_DATAROOTDIR "/vulkan/implicit_layer.d",
#endif
#ifdef INSTALL_FULL_SYSCONFDIR
INSTALL_FULL_SYSCONFDIR "/vulkan/implicit_layer.d",
INSTALL_FULL_SYSCONFDIR "/vulkan/implicit_layer.d",
#endif
};
#endif //_DEBUG
};

for (std::size_t i = 0, n = std::size(LAYERS_PATHS); i < n; ++i) {
for (std::size_t i = 0, n = std::size(LAYERS_PATHS); i < n; ++i) {
paths.push_back(LAYERS_PATHS[i]);
}
}

for (std::size_t i = 0, n = paths.size(); i < n; ++i) {
LayersPathInfo info;
info.type = LAYER_TYPE_IMPLICIT;
info.path = LAYERS_PATHS[i];
info.path = paths[i];
result.push_back(info);
}
#endif
Expand All @@ -100,24 +118,42 @@ std::vector<LayersPathInfo> GetExplicitLayerPaths() {
LoadRegistrySystemLayers("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Class\\...\\VulkanExplicitLayers");
result.insert(result.begin(), drivers_registry_paths.begin(), drivers_registry_paths.end());
#else
static const char *LAYERS_PATHS[] = {
"/usr/local/etc/vulkan/explicit_layer.d", // Not used on macOS, okay to just ignore
"/usr/local/share/vulkan/explicit_layer.d",
"/etc/vulkan/explicit_layer.d",
"/usr/share/vulkan/explicit_layer.d",
".local/share/vulkan/explicit_layer.d",
std::vector<std::string> paths;
if (VKC_PLATFORM == PLATFORM_MACOS) {
static const char *LAYERS_PATHS[] = {
"/usr/local/share/vulkan/explicit_layer.d",
".local/share/vulkan/explicit_layer.d",
};

for (std::size_t i = 0, n = std::size(LAYERS_PATHS); i < n; ++i) {
paths.push_back(LAYERS_PATHS[i]);
}
} else {
static const char *LAYERS_PATHS[] = {
"/usr/local/etc/vulkan/explicit_layer.d",
"/usr/local/share/vulkan/explicit_layer.d",
"/etc/vulkan/explicit_layer.d",
"/usr/share/vulkan/explicit_layer.d",
".local/share/vulkan/explicit_layer.d",
#ifdef _DEBUG
#ifdef INSTALL_FULL_DATAROOTDIR
INSTALL_FULL_DATAROOTDIR "/vulkan/explicit_layer.d",
INSTALL_FULL_DATAROOTDIR "/vulkan/explicit_layer.d",
#endif
#ifdef INSTALL_FULL_SYSCONFDIR
INSTALL_FULL_SYSCONFDIR "/vulkan/explicit_layer.d",
INSTALL_FULL_SYSCONFDIR "/vulkan/explicit_layer.d",
#endif
};
#endif //_DEBUG
};

for (std::size_t i = 0, n = std::size(LAYERS_PATHS); i < n; ++i) {
for (std::size_t i = 0, n = std::size(LAYERS_PATHS); i < n; ++i) {
paths.push_back(LAYERS_PATHS[i]);
}
}

for (std::size_t i = 0, n = paths.size(); i < n; ++i) {
LayersPathInfo info;
info.type = LAYER_TYPE_EXPLICIT;
info.path = LAYERS_PATHS[i];
info.path = paths[i];
result.push_back(info);
}
#endif
Expand Down Expand Up @@ -293,7 +329,7 @@ void LayerManager::InitSystemPaths() {
this->paths[LAYERS_PATHS_SDK].clear();
{
LayersPathInfo info;
info.path = ::Get(Path::SDK_BIN);
info.path = ::Get(Path::SDK_EXPLICIT_LAYERS);
info.enabled = true;
this->paths[LAYERS_PATHS_SDK].push_back(info);
}
Expand Down
95 changes: 54 additions & 41 deletions vkconfig_core/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ struct BuiltinDesc {
const Path::Builtin path;
};

static const BuiltinDesc VARIABLES[] = {{"${VK_HOME}", Path::HOME},
{"${VK_APPDATA}", Path::APPDATA},
{"${VULKAN_SDK}", Path::SDK},
{"${VULKAN_CONTENT}", Path::CONTENT}};
static const BuiltinDesc VARIABLES[] = {
{"${VK_HOME}", Path::HOME}, {"${VK_APPDATA}", Path::APPDATA}, {"${VULKAN_BIN}", Path::BIN},
{"${VULKAN_SDK}", Path::SDK}, {"${VULKAN_PROFILES}", Path::PROFILES}, {"${VULKAN_CONTENT}", Path::CONTENT}};

static std::string ConvertSeparators(const std::string& path, const char* native_separator, const char* alien_separator) {
const std::size_t native_separator_size = std::strlen(native_separator);
Expand Down Expand Up @@ -355,60 +354,72 @@ static const Path GetLoaderSettingsPath() {
}

static const Path GetSDKPath() {
std::string result = qgetenv("VULKAN_SDK").toStdString();
return result;
}

static const Path GetExplicitLayersPath() {
const std::string TABLE[] = {
"/Bin", // ENVIRONMENT_WIN32
"/share/vulkan/explicit_layer.d" // ENVIRONMENT_UNIX
};
static_assert(std::size(TABLE) == ENVIRONMENT_COUNT);

return GetSDKPath() + TABLE[VKC_ENV];
}

static const Path GetVulkanPath() {
const char* TABLE[] = {
"", // PLATFORM_WINDOWS_X86
"", // PLATFORM_WINDOWS_ARM
"/usr", // PLATFORM_LINUX
"/usr/local/share/vulkan", // PLATFORM_MACOS
"", // PLATFORM_ANDROID
"" // PLATFORM_IOS
"", // PLATFORM_WINDOWS_X86
"", // PLATFORM_WINDOWS_ARM
"/usr", // PLATFORM_LINUX
"/usr/local", // PLATFORM_MACOS
"", // PLATFORM_ANDROID
"" // PLATFORM_IOS
};
static_assert(std::size(TABLE) == PLATFORM_COUNT, "The tranlation table size doesn't match the enum number of elements");

std::string result = qgetenv("VULKAN_SDK").toStdString();
if (result.empty()) {
result = TABLE[VKC_PLATFORM];
} else { // VULKAN_SDK may be set on macOS
if (VKC_PLATFORM == PLATFORM_MACOS) {
result += "/share/vulkan";
}
Path path = GetSDKPath();
if (path.Empty()) {
return TABLE[VKC_PLATFORM];
} else {
return path;
}

return result;
}

static const Path GetSDKBinPath() {
const char* TABLE[] = {
static const Path GetVulkanBinPath() {
const std::string TABLE[] = {
"/Bin", // ENVIRONMENT_WIN32
"/bin", // ENVIRONMENT_UNIX
"/bin" // ENVIRONMENT_UNIX
};
static_assert(std::size(TABLE) == ENVIRONMENT_COUNT);

return GetSDKPath() + TABLE[VKC_ENV];
Path path = GetVulkanPath();
if (path.Empty()) {
return "";
}

return GetVulkanPath() + TABLE[VKC_ENV];
}

static const Path GetExplicitLayersPath() {
static const std::string TABLE[] = {
"/Bin", // ENVIRONMENT_WIN32
"/etc/vulkan/explicit_layer.d" // ENVIRONMENT_UNIX
static const Path GetVulkanContentPath() {
const std::string TABLE[] = {
"/Config", // ENVIRONMENT_WIN32
"/share/vulkan/config" // ENVIRONMENT_UNIX
};
static_assert(std::size(TABLE) == ENVIRONMENT_COUNT);

return GetSDKPath().RelativePath() + TABLE[VKC_ENV];
return GetVulkanPath().RelativePath() + TABLE[VKC_ENV];
}

static const Path GetVulkanContentPath() {
static const std::string TABLE[] = {
"/Config", // PLATFORM_WINDOWS_86
"/Config", // PLATFORM_WINDOWS_ARM
"/share/vulkan/config", // PLATFORM_LINUX
"/config", // PLATFORM_MACOS
"N/A", // PLATFORM_ANDROID
"N/A" // PLATFORM_IOS
static const Path GetVulkanProfilesPath() {
const std::string TABLE[] = {
"/Config/VK_LAYER_KHRONOS_profiles", // ENVIRONMENT_WIN32
"/share/vulkan/config/VK_LAYER_KHRONOS_profiles" // ENVIRONMENT_UNIX
};
static_assert(std::size(TABLE) == PLATFORM_COUNT);
static_assert(std::size(TABLE) == ENVIRONMENT_COUNT);

return GetSDKPath().RelativePath() + TABLE[VKC_PLATFORM];
return GetVulkanPath().RelativePath() + TABLE[VKC_ENV];
}

Path Get(Path::Builtin path) {
Expand All @@ -430,14 +441,16 @@ Path Get(Path::Builtin path) {
return ::GetLayersSettingsPath();
case Path::LOADER_SETTINGS:
return ::GetLoaderSettingsPath();
case Path::BIN:
return ::GetVulkanBinPath();
case Path::SDK:
return ::GetSDKPath();
case Path::SDK_BIN:
return ::GetSDKBinPath();
case Path::EXPLICIT_LAYERS:
case Path::SDK_EXPLICIT_LAYERS:
return ::GetExplicitLayersPath();
case Path::CONTENT:
return ::GetVulkanContentPath();
case Path::PROFILES:
return ::GetVulkanProfilesPath();
}
}

Expand Down
7 changes: 4 additions & 3 deletions vkconfig_core/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ class Path {
CONFIGS,
LAYERS_SETTINGS,
LOADER_SETTINGS,
BIN,
SDK,
SDK_BIN,
EXPLICIT_LAYERS,
CONTENT,
SDK_EXPLICIT_LAYERS,
PROFILES,
CONTENT
};

Path();
Expand Down
27 changes: 16 additions & 11 deletions vkconfig_core/test/test_executable_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ TEST(test_executable_manager, reset_default_applications_sdk_found) {
std::string result = qgetenv("VULKAN_SDK").toStdString();

if (!result.empty()) {
EXPECT_EQ(2, executables.size());
EXPECT_EQ(3, executables.size());

// Make sure the variable are not replaced
EXPECT_TRUE(executables[0].path.RelativePath().find("${VULKAN_SDK}") != std::string::npos);

EXPECT_TRUE(executables[0].path.RelativePath().find("${VULKAN_BIN}") != std::string::npos);
const std::vector<ExecutableOptions>& options0 = executables[0].GetOptions();
EXPECT_TRUE(options0[0].working_folder.RelativePath().find("${VULKAN_SDK}") != std::string::npos);
EXPECT_TRUE(options0[0].working_folder.RelativePath().find("${VULKAN_BIN}") != std::string::npos);
EXPECT_TRUE(options0[0].log_file.RelativePath().find("${VK_HOME}") != std::string::npos);

EXPECT_TRUE(executables[1].path.RelativePath().find("${VULKAN_SDK}") != std::string::npos);

EXPECT_TRUE(executables[1].path.RelativePath().find("${VULKAN_BIN}") != std::string::npos);
const std::vector<ExecutableOptions>& options1 = executables[1].GetOptions();
EXPECT_TRUE(options1[0].working_folder.RelativePath().find("${VULKAN_SDK}") != std::string::npos);
EXPECT_TRUE(options1[0].working_folder.RelativePath().find("${VULKAN_BIN}") != std::string::npos);
EXPECT_TRUE(options1[0].log_file.RelativePath().find("${VK_HOME}") != std::string::npos);

EXPECT_TRUE(executables[2].path.RelativePath().find("${VULKAN_BIN}") != std::string::npos);
const std::vector<ExecutableOptions>& options2 = executables[2].GetOptions();
EXPECT_TRUE(options2[0].working_folder.RelativePath().find("${VULKAN_BIN}") != std::string::npos);
EXPECT_TRUE(options2[0].log_file.RelativePath().find("${VK_HOME}") != std::string::npos);
}
}

Expand All @@ -58,20 +61,22 @@ TEST(test_executable_manager, reset_default_applications_no_sdk) {

const std::vector<Executable>& executables = executable_manager.GetExecutables();

EXPECT_EQ(2, executables.size());
EXPECT_EQ(3, executables.size());

// Make sure the variable are not replaced
EXPECT_TRUE(executables[0].path.RelativePath().find("vkcube") != std::string::npos);

const std::vector<ExecutableOptions>& options0 = executables[0].GetOptions();
EXPECT_TRUE(options0[0].working_folder.RelativePath().find(".") != std::string::npos);
EXPECT_TRUE(options0[0].log_file.RelativePath().find("${VK_HOME}") != std::string::npos);

EXPECT_TRUE(executables[1].path.RelativePath().find("vkcubepp") != std::string::npos);

const std::vector<ExecutableOptions>& options1 = executables[1].GetOptions();
EXPECT_TRUE(options1[0].working_folder.RelativePath().find(".") != std::string::npos);
EXPECT_TRUE(options1[0].log_file.RelativePath().find("${VK_HOME}") != std::string::npos);

EXPECT_TRUE(executables[2].path.RelativePath().find("vulkaninfo") != std::string::npos);
const std::vector<ExecutableOptions>& options2 = executables[2].GetOptions();
EXPECT_TRUE(options2[0].working_folder.RelativePath().find(".") != std::string::npos);
EXPECT_TRUE(options2[0].log_file.RelativePath().find("${VK_HOME}") != std::string::npos);
}

TEST(test_executable_manager, remove_missing_applications) {
Expand Down
Loading