Browse Source

Make it compile on Linux

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
5b27d06f8c

+ 1 - 1
AnKi/Core/GpuMemoryPools.cpp

@@ -116,7 +116,7 @@ PtrSize RebarStagingGpuMemoryPool::endFrame()
 
 	if(usedMemory >= PtrSize(0.8 * F64(m_bufferSize / kMaxFramesInFlight)))
 	{
-		ANKI_CORE_LOGW("Frame used more that 80% of its safe limit of ReBAR memory");
+		ANKI_CORE_LOGW("Frame used more that 80%% of its safe limit of ReBAR memory");
 	}
 
 	ANKI_TRACE_INC_COUNTER(ReBarUsedMemory, usedMemory);

+ 12 - 5
AnKi/ShaderCompiler/Dxc.cpp

@@ -11,6 +11,8 @@
 
 namespace anki {
 
+static Atomic<U32> g_nextFileId = {1};
+
 static CString profile(ShaderType shaderType)
 {
 	switch(shaderType)
@@ -51,7 +53,8 @@ static CString profile(ShaderType shaderType)
 Error compileHlslToSpirv(CString src, ShaderType shaderType, BaseMemoryPool& tmpPool, DynamicArrayRaii<U8>& spirv,
 						 StringRaii& errorMessage)
 {
-	const U64 rand = getRandom();
+	Array<U64, 3> toHash = {g_nextFileId.fetchAdd(1), getCurrentProcessId(), getRandom() & kMaxU32};
+	const U64 rand = computeHash(&toHash[0], sizeof(toHash));
 
 	StringRaii tmpDir(&tmpPool);
 	ANKI_CHECK(getTempDirectory(tmpDir));
@@ -102,15 +105,19 @@ Error compileHlslToSpirv(CString src, ShaderType shaderType, BaseMemoryPool& tmp
 		I32 exitCode;
 		StringRaii stdOut(&tmpPool);
 
+#if ANKI_OS_WINDOWS
+		CString dxcBin = ANKI_SOURCE_DIRECTORY "/ThirdParty/Bin/Windows64/dxc.exe";
+#elif ANKI_OS_LINUX
+		CString dxcBin = ANKI_SOURCE_DIRECTORY "/ThirdParty/Bin/Linux64/dxc";
+#endif
+
 		// Run once without stdout or stderr. Because if you do the process library will crap out after a while
-		ANKI_CHECK(Process::callProcess(ANKI_SOURCE_DIRECTORY "/ThirdParty/Bin/Windows64/dxc.exe", dxcArgs2, nullptr,
-										nullptr, exitCode));
+		ANKI_CHECK(Process::callProcess(dxcBin, dxcArgs2, nullptr, nullptr, exitCode));
 
 		if(exitCode != 0)
 		{
 			// There was an error, run again just to get the stderr
-			ANKI_CHECK(Process::callProcess(ANKI_SOURCE_DIRECTORY "/ThirdParty/Bin/Windows64/dxc.exe", dxcArgs2,
-											nullptr, &errorMessage, exitCode));
+			ANKI_CHECK(Process::callProcess(dxcBin, dxcArgs2, nullptr, &errorMessage, exitCode));
 
 			if(!errorMessage.isEmpty()
 			   && errorMessage.find("The process cannot access the file because") != CString::kNpos)

+ 1 - 1
AnKi/Shaders/ApplyIrradianceToReflection.ankiprog

@@ -17,7 +17,7 @@ layout(set = 0, binding = 2) buffer readonly b_ssbo
 	ANKI_RP Vec4 u_irradianceDice[6u];
 };
 
-layout(set = 0, binding = 3, r11f_g11f_b10f) uniform ANKI_RP imageCube u_cubeTex;
+layout(set = 0, binding = 3) uniform ANKI_RP imageCube u_cubeTex;
 
 void main()
 {

+ 1 - 1
AnKi/Util/Logger.cpp

@@ -180,7 +180,7 @@ void Logger::defaultSystemMessageHandler(void*, const LoggerMessageInfo& info)
 		endTerminalColor = "";
 	}
 
-	fprintf(out, "%s[%s][%s]%s%s %s [%s:%d][%s][%s]%s\n", terminalColorBg, kMessageTypeTxt[U(info.m_type)],
+	fprintf(out, "%s[%s][%-4s]%s%s %s [%s:%d][%s][%s]%s\n", terminalColorBg, kMessageTypeTxt[U(info.m_type)],
 			info.m_subsystem ? info.m_subsystem : "N/A ", endTerminalColor, terminalColor, info.m_msg, info.m_file,
 			info.m_line, info.m_func, info.m_threadName, endTerminalColor);
 #elif ANKI_OS_WINDOWS

BIN
ThirdParty/Bin/Linux64/clang-format


+ 7 - 0
ThirdParty/Bin/Linux64/dxc

@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
+
+export LD_LIBRARY_PATH=$SCRIPT_DIR:$LD_LIBRARY_PATH
+
+$SCRIPT_DIR/dxc.bin "$@"

BIN
ThirdParty/Bin/Linux64/dxc.bin


+ 1 - 0
ThirdParty/Bin/Linux64/libdxcompiler.so

@@ -0,0 +1 @@
+libdxcompiler.so.3.7

BIN
ThirdParty/Bin/Linux64/libdxcompiler.so.3.7


+ 7 - 2
Tools/FormatSource.py

@@ -12,6 +12,7 @@ import multiprocessing
 import os
 import tempfile
 import shutil
+import platform
 
 file_extensions = ["h", "hpp", "c", "cpp", "glsl", "hlsl", "ankiprog"]
 directories = ["AnKi", "Tests", "Sandbox", "Tools", "Samples"]
@@ -61,8 +62,12 @@ def thread_callback(tid):
         else:
             style_file = "--style=file:.clang-format"
 
-        subprocess.check_call(["./ThirdParty/Bin/Windows64/clang-format.exe",
-                              "-sort-includes=false", style_file, "-i", file_name])
+        if platform.system() == "Linux":
+            exe = "./ThirdParty/Bin/Linux64/clang-format"
+        else:
+            exe = "./ThirdParty/Bin/Windows64/clang-format.exe"
+
+        subprocess.check_call([exe, "-sort-includes=false", style_file, "-i", file_name])
 
         if is_shader:
             shutil.move(tmp_filename, orig_filename)