diff --git a/Dependencies/libsodium/libsodium.lua b/Dependencies/libsodium/libsodium.lua index 55da7431..9178c00b 100644 --- a/Dependencies/libsodium/libsodium.lua +++ b/Dependencies/libsodium/libsodium.lua @@ -9,7 +9,7 @@ Solution.Util.CreateDep(dep.Name, dep.Dependencies, function() Solution.Util.SetLibDirs(libPath) Solution.Util.SetLinks(lib) else - Solution.Util.SetLinks("libsodium") + Solution.Util.SetLinks("sodium") end Solution.Util.SetIncludes(dep.Path) diff --git a/Dependencies/slang/slang.lua b/Dependencies/slang/slang.lua index f3f34928..d4d6ae07 100644 --- a/Dependencies/slang/slang.lua +++ b/Dependencies/slang/slang.lua @@ -1,40 +1,134 @@ -local vkSdk = os.getenv("VULKAN_SDK") -if not vkSdk then - Solution.Util.PrintError("VULKAN_SDK not found. Please ensure Vulkan SDK is installed.") -end +local function getSlangInfo() + if os.target() == "linux" then + local includeDirs = {} + local libDirs = {} + local runtimeLibraries = {} --- Determine platform-specific library paths -local libName, libSrcPath -if os.target() == "windows" then - libName = "slang.dll" - libSrcPath = vkSdk .. "/bin/" .. libName -else - libName = "libslang.so" - libSrcPath = vkSdk .. "/lib/" .. libName -end + if os.host() == "linux" then + local slangSDK = os.getenv("SLANG_SDK") or os.getenv("VULKAN_SDK") + local includeDir + local libDir + + if slangSDK then + includeDir = slangSDK .. "/include" + libDir = slangSDK .. "/lib" + + if not os.isfile(includeDir .. "/slang/slang.h") then + Solution.Util.PrintError( + "The configured SDK does not contain Slang headers: '" .. includeDir .. "'." + ) + end + + if not os.isfile(libDir .. "/libslang.so") then + Solution.Util.PrintError( + "The configured SDK does not contain the Slang library: '" .. libDir .. "'." + ) + end + else + includeDir = os.findheader("slang/slang.h") + libDir = os.findlib("slang") + end + + if not includeDir then + Solution.Util.PrintError( + "Failed to find the Slang headers in the system include paths. " .. + "Source the Vulkan SDK's setup-env.sh, set SLANG_SDK, or install Slang system-wide." + ) + end + + if not libDir then + Solution.Util.PrintError( + "Failed to find the Slang shared library in the system library paths. " .. + "Source the Vulkan SDK's setup-env.sh, set SLANG_SDK, or install Slang system-wide." + ) + end + + table.insert(includeDirs, includeDir) + table.insert(libDirs, libDir) + + if slangSDK then + runtimeLibraries = os.matchfiles(libDir .. "/libslang*.so*") + end + end + + -- Requiring slang/slang.h distinguishes Shader Slang from the unrelated + -- S-Lang terminal library commonly installed by Linux distributions. + return { + includeDirs = includeDirs, + libDirs = libDirs, + runtimeLibraries = runtimeLibraries + } + end + + -- Newer Vulkan SDKs bundle Slang. SLANG_SDK also permits a standalone Slang + -- installation without forcing Vulkan and Slang to share an SDK root. + local slangSDK = os.getenv("SLANG_SDK") or os.getenv("VULKAN_SDK") + if not slangSDK then + Solution.Util.PrintError( + "Failed to find Slang. Please set SLANG_SDK to the Slang SDK root, " .. + "or VULKAN_SDK when using a Vulkan SDK that bundles Slang." + ) + end --- Copy shared library (release version always) during premake generation -local binDir = Solution.Projects.Current.BinDir -local configs = { "Debug", "RelDebug", "Release" } - -for _, cfg in ipairs(configs) do - local destDir = binDir .. "/" .. cfg - os.mkdir(destDir) - - local destPath = destDir .. "/" .. libName - local success, err = os.copyfile(libSrcPath, destPath) - if success then - Solution.Util.Print("Copied " .. libName .. " to " .. destDir) + local runtimeLibraries + if os.target() == "windows" then + runtimeLibraries = { slangSDK .. "/bin/slang.dll" } else - Solution.Util.PrintError("Failed to copy " .. libName .. ": " .. (err or "unknown error")) + runtimeLibraries = os.matchfiles(slangSDK .. "/lib/libslang*.so*") + end + + return { + includeDirs = { slangSDK .. "/include" }, + libDirs = { slangSDK .. "/lib" }, + runtimeLibraries = runtimeLibraries + } +end + +local function copyRuntimeLibraries(runtimeLibraries) + if not runtimeLibraries or #runtimeLibraries == 0 then + return + end + + -- Root projects can place executables one level above the Engine bin directory. + local binDir = Solution.Projects.Current.BinDir + local binDirs = { binDir } + local parentBinDir = path.getdirectory(binDir) + if parentBinDir and parentBinDir ~= binDir then + table.insert(binDirs, parentBinDir) + end + + local configs = { "Debug", "RelDebug", "Release" } + + for _, runtimeLibrary in ipairs(runtimeLibraries) do + local runtimeLibraryName = path.getname(runtimeLibrary) + + for _, cfgDir in ipairs(binDirs) do + for _, cfg in ipairs(configs) do + local destDir = cfgDir .. "/" .. cfg + os.mkdir(destDir) + + local destPath = destDir .. "/" .. runtimeLibraryName + local success, err = os.copyfile(runtimeLibrary, destPath) + if success then + Solution.Util.Print("Copied " .. runtimeLibraryName .. " to " .. destDir) + else + Solution.Util.PrintError( + "Failed to copy " .. runtimeLibraryName .. " from '" .. runtimeLibrary .. "': " .. + (err or "unknown error") + ) + end + end + end end end --- Create dependency +local slangInfo = getSlangInfo() +copyRuntimeLibraries(slangInfo.runtimeLibraries) + local dep = Solution.Util.CreateDepTable("Slang-Slang", {}) Solution.Util.CreateDep(dep.NameLow, dep.Dependencies, function() - Solution.Util.SetIncludes(vkSdk .. "/include") - Solution.Util.SetLibDirs(vkSdk .. "/lib") + Solution.Util.SetIncludes(slangInfo.includeDirs) + Solution.Util.SetLibDirs(slangInfo.libDirs) Solution.Util.SetLinks("slang") end) diff --git a/Dependencies/vulkan/vulkan.lua b/Dependencies/vulkan/vulkan.lua index e5207104..89df92f4 100644 --- a/Dependencies/vulkan/vulkan.lua +++ b/Dependencies/vulkan/vulkan.lua @@ -1,24 +1,73 @@ local function getVulkanInfo() - local envName = "VULKAN_SDK" local includeDirs = {} + local libDirs = {} local libs = {} - - local vulkanSDK = os.getenv(envName) - if not vulkanSDK then - Solution.Util.PrintError("Failed to find Vulkan SDK with system variable '" .. envName .. "'. Please ensure Vulkan is installed and configured properly") - end - - -- Add Includes path - table.insert(includeDirs, vulkanSDK .. "/include") - - -- Add Library - if os.target() == "windows" then - table.insert(libs, vulkanSDK .. "/lib/vulkan-1.lib") - else + + if os.target() == "linux" then + if os.host() == "linux" then + local vulkanSDK = os.getenv("VULKAN_SDK") + local includeDir + local libDir + + if vulkanSDK then + includeDir = vulkanSDK .. "/include" + libDir = vulkanSDK .. "/lib/VulkanLoader/lib" + + if not os.isfile(includeDir .. "/vulkan/vulkan.h") then + Solution.Util.PrintError( + "VULKAN_SDK does not contain Vulkan headers: '" .. includeDir .. "'." + ) + end + + if not os.isfile(libDir .. "/libvulkan.so") then + Solution.Util.PrintError( + "VULKAN_SDK does not contain the Vulkan loader: '" .. libDir .. "'." + ) + end + else + includeDir = os.findheader("vulkan/vulkan.h") + libDir = os.findlib("vulkan") + end + + if not includeDir then + Solution.Util.PrintError( + "Failed to find the Vulkan headers in the system include paths. " .. + "Source the Vulkan SDK's setup-env.sh, or install the Vulkan development packages." + ) + end + + if not libDir then + Solution.Util.PrintError( + "Failed to find the Vulkan loader in the system library paths. " .. + "Source the Vulkan SDK's setup-env.sh, or install the Vulkan development packages." + ) + end + + table.insert(includeDirs, includeDir) + table.insert(libDirs, libDir) + end + table.insert(libs, "vulkan") + else + local envName = "VULKAN_SDK" + local vulkanSDK = os.getenv(envName) + if not vulkanSDK then + Solution.Util.PrintError( + "Failed to find the Vulkan SDK with system variable '" .. envName .. "'. " .. + "Please ensure Vulkan is installed and configured properly." + ) + end + + table.insert(includeDirs, vulkanSDK .. "/include") + + if os.target() == "windows" then + table.insert(libs, vulkanSDK .. "/lib/vulkan-1.lib") + else + table.insert(libs, "vulkan") + end end - - return includeDirs, libs + + return includeDirs, libDirs, libs end local dep = Solution.Util.CreateDepTable("vulkan", {}) @@ -26,15 +75,20 @@ local dep = Solution.Util.CreateDepTable("vulkan", {}) Solution.Util.CreateDep(dep.Name, dep.Dependencies, function() local cachedData = Solution.Util.GetDepCache(dep.Name, "cache") - local includeDirs, libs + local includeDirs, libDirs, libs if cachedData then - includeDirs, libs = cachedData.includes, cachedData.libs + includeDirs, libDirs, libs = cachedData.includes, cachedData.libDirs, cachedData.libs else - includeDirs, libs = getVulkanInfo() - Solution.Util.SetDepCache(dep.Name, "cache", { includes = includeDirs, libs = libs }) + includeDirs, libDirs, libs = getVulkanInfo() + Solution.Util.SetDepCache(dep.Name, "cache", { + includes = includeDirs, + libDirs = libDirs, + libs = libs + }) end Solution.Util.SetIncludes(includeDirs) + Solution.Util.SetLibDirs(libDirs) Solution.Util.SetLinks(libs) Solution.Util.SetDefines({ "_CRT_SECURE_NO_WARNINGS" }) -end) \ No newline at end of file +end) diff --git a/Premake/ProjectUtil.lua b/Premake/ProjectUtil.lua index 0030dd0c..8892649d 100644 --- a/Premake/ProjectUtil.lua +++ b/Premake/ProjectUtil.lua @@ -44,8 +44,8 @@ end systemToExecutableExtensionMap = { - windows = "exe", - linux = "sh" + windows = ".exe", + linux = "" } systemToDynamicLibExtensionMap = @@ -237,6 +237,11 @@ Solution.Util.CreateProject = function(name, projectType, binDir, dependencies, characterset ("ASCII") editandcontinue "Off" + filter "system:linux" + linkgroups "On" + linkoptions { "-Wl,-rpath,'$$ORIGIN'" } + filter {} + filter "configurations:Debug" runtime "Debug" symbols "On" diff --git a/Source/Base/Base/Platform.h b/Source/Base/Base/Platform.h index b734db86..e1f3e3e6 100644 --- a/Source/Base/Base/Platform.h +++ b/Source/Base/Base/Platform.h @@ -50,8 +50,8 @@ inline void ReleaseModeBreakpoint() #endif #if defined(__clang__) -#define PRAGMA_NO_PADDING_START __pragma(pack(push, 1)) -#define PRAGMA_NO_PADDING_END __pragma(pack(pop)) +#define PRAGMA_NO_PADDING_START _Pragma("pack(push, 1)") +#define PRAGMA_NO_PADDING_END _Pragma("pack(pop)") #elif defined(_MSC_VER) #define PRAGMA_NO_PADDING_START __pragma(pack(push, 1)) diff --git a/Source/Base/Base/Types.h b/Source/Base/Base/Types.h index b30b6b0c..0621889a 100644 --- a/Source/Base/Base/Types.h +++ b/Source/Base/Base/Types.h @@ -48,9 +48,9 @@ struct EnumTraits; inline const T operator| (T a, T b) { return (T)((i32)a | (i32)b); } \ inline const T operator& (T a, T b) { return (T)((i32)a & (i32)b); } \ inline const T operator^ (T a, T b) { return (T)((i32)a ^ (i32)b); } \ -inline const T& operator|= (T& a, T b) { return (T&)((i32&)a |= (i32)b); } \ -inline const T& operator&= (T& a, T b) { return (T&)((i32&)a &= (i32)b); } \ -inline const T& operator^= (T& a, T b) { return (T&)((i32&)a ^= (i32)b); } +inline const T& operator|= (T& a, T b) { a = (T)((i32)a | (i32)b); return a; } \ +inline const T& operator&= (T& a, T b) { a = (T)((i32)a & (i32)b); return a; } \ +inline const T& operator^= (T& a, T b) { a = (T)((i32)a ^ (i32)b); return a; } // Define extra implicit conversions for ImGui vector classes #define IM_VEC2_CLASS_EXTRA \ diff --git a/Source/Filesystem/Filesystem/Core/File.cpp b/Source/Filesystem/Filesystem/Core/File.cpp index 0872bd0a..84b3a902 100644 --- a/Source/Filesystem/Filesystem/Core/File.cpp +++ b/Source/Filesystem/Filesystem/Core/File.cpp @@ -8,6 +8,7 @@ #include #include +#include namespace fs = std::filesystem; diff --git a/Source/Gameplay/Gameplay/Network/GameMessageRouter.h b/Source/Gameplay/Gameplay/Network/GameMessageRouter.h index 2591a3b4..ed15e651 100644 --- a/Source/Gameplay/Gameplay/Network/GameMessageRouter.h +++ b/Source/Gameplay/Gameplay/Network/GameMessageRouter.h @@ -60,7 +60,7 @@ namespace Network } template - void UnregisterPacketHandler(OpcodeType opcode) + void UnregisterPacketHandler(OpcodeType /*opcode*/) { auto opcode = static_cast(PacketStruct::PACKET_ID); diff --git a/Source/Renderer/Renderer/Renderers/Vulkan/Backend/SpirvReflect.h b/Source/Renderer/Renderer/Renderers/Vulkan/Backend/SpirvReflect.h index c6e13ee9..46e4768e 100644 --- a/Source/Renderer/Renderer/Renderers/Vulkan/Backend/SpirvReflect.h +++ b/Source/Renderer/Renderer/Renderers/Vulkan/Backend/SpirvReflect.h @@ -33,8 +33,14 @@ VERSION HISTORY #define SPIRV_REFLECT_USE_SYSTEM_SPIRV_H #if defined(SPIRV_REFLECT_USE_SYSTEM_SPIRV_H) +#if __has_include() +#include +#elif __has_include() #include #else +#error "Unable to locate SPIR-V headers" +#endif +#else #include "./include/spirv/unified1/spirv.h" #endif @@ -2465,4 +2471,4 @@ namespace spv_reflect { #endif // defined(__cplusplus) && !defined(SPIRV_REFLECT_DISABLE_CPP_WRAPPER) #endif // SPIRV_REFLECT_H -// clang-format on \ No newline at end of file +// clang-format on diff --git a/Source/ShaderCooker/ShaderCooker/SlangBridge.cpp b/Source/ShaderCooker/ShaderCooker/SlangBridge.cpp index 68d9d399..ff6a8915 100644 --- a/Source/ShaderCooker/ShaderCooker/SlangBridge.cpp +++ b/Source/ShaderCooker/ShaderCooker/SlangBridge.cpp @@ -71,7 +71,7 @@ namespace ShaderCooker (char*)"ms", // Mesh Shader (char*)"as" // Amplification Shader (used with Mesh Shaders) }; - constexpr i32 ProfileToProfileIndex(const std::string& profile) + inline i32 ProfileToProfileIndex(const std::string& profile) { i32 currentProfileIndex = 0; for (char* validProfile : validProfilesArray)