diff --git a/Source/Engine/GraphicsDevice/Vulkan/GraphicsDeviceVulkan.Build.cs b/Source/Engine/GraphicsDevice/Vulkan/GraphicsDeviceVulkan.Build.cs index c56619a0f..b2780f7ca 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GraphicsDeviceVulkan.Build.cs +++ b/Source/Engine/GraphicsDevice/Vulkan/GraphicsDeviceVulkan.Build.cs @@ -40,20 +40,29 @@ public sealed class VulkanSdk : Sdk return; var vulkanSdk = Environment.GetEnvironmentVariable("VULKAN_SDK"); - if (platform == TargetPlatform.Mac && (vulkanSdk == null || !Directory.Exists(vulkanSdk))) + if (vulkanSdk == null || !Directory.Exists(vulkanSdk)) { - // Try to guess install location for the current user - var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "VulkanSDK"); - if (Directory.Exists(path)) + if (platform == TargetPlatform.Mac) { - var subDirs = Directory.GetDirectories(path); - if (subDirs.Length != 0) + // Try to guess install location for the current user + var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "VulkanSDK"); + if (Directory.Exists(path)) { - path = Path.Combine(subDirs[0], "macOS"); - if (Directory.Exists(path)) - vulkanSdk = path; + var subDirs = Directory.GetDirectories(path); + if (subDirs.Length != 0) + { + path = Path.Combine(subDirs[0], "macOS"); + if (Directory.Exists(path)) + vulkanSdk = path; + } } } + else if (platform == TargetPlatform.Linux) + { + // Try to use system-installed Vulkan SDK + if (File.Exists("/usr/include/vulkan/vulkan.h")) + vulkanSdk = "/usr/include"; + } } if (vulkanSdk != null) { @@ -87,13 +96,20 @@ public sealed class VulkanSdk : Sdk { var vulkanSdk = RootPath; + // Use system-installed headers + if (vulkanSdk.EndsWith("/include") && Directory.Exists(vulkanSdk)) + { + includesFolderPath = vulkanSdk; + return true; + } + + // Check potential location with headers var includes = new[] { Path.Combine(vulkanSdk, "include"), Path.Combine(vulkanSdk, "Include"), Path.Combine(vulkanSdk, "x86_64", "include"), }; - foreach (var include in includes) { if (Directory.Exists(include)) diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index a5bd099c9..3effd5d03 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -840,17 +840,17 @@ int X11ErrorHandler(X11::Display* display, X11::XErrorEvent* event) int32 CalculateDpi() { - // in X11 a screen is not necessarily identical to a desktop - // so we need to stick to one type for pixel and physical size query + int dpi = 96; + char* resourceString = X11::XResourceManagerString(xDisplay); + if (resourceString == NULL) + return dpi; - int screenIdx = 0; - int widthMM = X11_DisplayWidthMM(xDisplay, screenIdx); - int heightMM = X11_DisplayHeightMM(xDisplay, screenIdx); - double xdpi = (widthMM ? X11_DisplayWidth(xDisplay, screenIdx) / (double)widthMM * 25.4 : 0); - double ydpi = (heightMM ? X11_DisplayHeight(xDisplay, screenIdx) / (double)heightMM * 25.4 : 0); - if (xdpi || ydpi) - return (int32)Math::Ceil((xdpi + ydpi) / (xdpi && ydpi ? 2 : 1)); - return 96; + char* type = NULL; + X11::XrmValue value; + X11::XrmDatabase database = X11::XrmGetStringDatabase(resourceString); + if (X11::XrmGetResource(database, "Xft.dpi", "String", &type, &value) == 1 && value.addr != NULL) + dpi = (int)atof(value.addr); + return dpi; } // Maps Flax key codes to X11 names for physical key locations. @@ -2101,6 +2101,7 @@ bool LinuxPlatform::Init() xAtomWmName = X11::XInternAtom(xDisplay, "_NET_WM_NAME", 0); xAtomClipboard = X11::XInternAtom(xDisplay, "CLIPBOARD", 0); + X11::XrmInitialize(); SystemDpi = CalculateDpi(); int cursorSize = X11::XcursorGetDefaultSize(xDisplay); diff --git a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs index 9bc9aab33..1a0557c94 100644 --- a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs @@ -24,14 +24,30 @@ namespace Flax.Build.Platforms { // Setup system paths var includePath = Path.Combine(ToolsetRoot, "usr", "include"); + if (!Directory.Exists(includePath)) + { + var error = $"Missing toolset header files location {includePath}"; + Log.Error(error); + } SystemIncludePaths.Add(includePath); var cppIncludePath = Path.Combine(includePath, "c++", ClangVersion.ToString()); - if (Directory.Exists(cppIncludePath)) - SystemIncludePaths.Add(cppIncludePath); + if (!Directory.Exists(cppIncludePath)) + { + var error = $"Missing Clang {ClangVersion} C++ header files location {cppIncludePath}"; + cppIncludePath = Path.Combine(ToolsetRoot, "usr", "lib", "llvm-" + ClangVersion.Major.ToString(), "include", "c++", "v1"); + if (!Directory.Exists(cppIncludePath)) + Log.Error(error); + } + SystemIncludePaths.Add(cppIncludePath); var clangLibPath = Path.Combine(ToolsetRoot, "usr", "lib", "clang"); var clangIncludePath = Path.Combine(clangLibPath, ClangVersion.Major.ToString(), "include"); if (!Directory.Exists(clangIncludePath)) + { + var error = $"Missing Clang {ClangVersion} header files location {clangIncludePath}"; clangIncludePath = Path.Combine(clangLibPath, ClangVersion.ToString(), "include"); + if (!Directory.Exists(clangIncludePath)) + Log.Error(error); + } SystemIncludePaths.Add(clangIncludePath); }