Bläddra i källkod

WIP: Linux port
- Fixed a deadlock on FolderMonitor shutdown
- Fixed an issue causing warnings due to incorrect field types in DockDropOverlay shaders
- Updated Mono compilation documentation

Marko Pintera 8 år sedan
förälder
incheckning
232db4668a

BIN
Data/Editor/Shaders/DockDropOverlay.bsl.asset


+ 4 - 4
Data/Raw/Editor/Shaders/DockDropOverlay.bsl

@@ -22,9 +22,9 @@ technique DockDropOverlay
 			float invViewportWidth;
 			float invViewportWidth;
 			float invViewportHeight;
 			float invViewportHeight;
 
 
-			float4 tintColor;
-			float4 highlightColor;
-			float4 highlightActive;
+			[color]	float4 tintColor;
+			[color]	float4 highlightColor;
+			[color]	float4 highlightActive;
 		};
 		};
 
 
 		void vsmain(
 		void vsmain(
@@ -49,4 +49,4 @@ technique DockDropOverlay
 			return color;
 			return color;
 		}	
 		}	
 	};
 	};
-};
+};

+ 2 - 2
Documentation/GitHub/dependencies.md

@@ -67,11 +67,11 @@ Additionally, if the dependency structure still isn't clear, download one of the
 - Compile as a static library
 - Compile as a static library
    
    
 **mono**
 **mono**
-- Mono 4.4.0
+- Mono 5.4
 - http://www.mono-project.com/
 - http://www.mono-project.com/
 - Required by BansheeMono
 - Required by BansheeMono
 - Compile as a dynamic library
 - Compile as a dynamic library
- - See Mono-4.4.0-IntegrationGuide.txt for additional notes
+ - See MonoIntegrationGuide.txt for additional notes
    
    
 **PhysX**
 **PhysX**
 - PhysX 3.3
 - PhysX 3.3

+ 0 - 53
Documentation/Mono-4.4.0-IntegrationGuide.txt

@@ -1,53 +0,0 @@
----------------------------------Compiling runtime-------------------------------------
- - Retrieve mono sources using git:
-   - (Windows only) Make sure your git client has this set: "git config --global core.autocrlf input" as otherwise you'll have problems with line endings during later steps
-   - Clone mono from https://github.com/mono/mono (make sure to perform a RECURSIVE clone as there are sub-modules in the /external folder)
-     - Checkout mono-4.4.0-branch
-     - Checkout commit # febc509ab9a7d07734f5b694037bc2becbc97851 (later ones might, but might not work)
- - If on Windows:
-  - Go to msvc/ folder to find mono.sln (Visual studio solution)
-  - Open in VS2012 as is, or open in later VS and upgrade all projects to latest toolkit (v120 and v140 tested and working)
- - Expose "mono_class_bind_generic_parameters" to the public:
-  - In mono/metadata/object-internals.h change:
-   MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic) MONO_INTERNAL; 
-   to:
-   MONO_API MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, mono_bool is_dynamic);
-   then move it to:
-   mono/metadata/object.h
-  - In mono/metadata/reflection.c modify:
-   MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic)
-   to:
-   MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, mono_bool is_dynamic)
-  - (Windows only) Add "mono_class_bind_generic_parameters" entry to mono/msvc/mono.def file
- - (Windows only) Generate missing header files:
-   - First compile "genmdesc" project for desired configuration (debug/release, 32/64 bit)
-   - Then run "runmdesc x64\bin\Debug\genmdesc x64" located in /msvc folder
-     - Replace folder path to genmdesc you generated in the previous step
-	 - Replace x64 with Win32 for 32-bit builds
- - Compile mono project with desired configuration (debug/release, 32/64 bit, SGen builds were not tested). You will receive mono-2.0.dll and mono-2.0.lib as output.
-   - Repeat the "genmdesc" step above for each configuration. Doing it once might be enough but be on the safe side.
-
------------------------------Compiling libraries & compiler -------------------------------------
-
-- Install Mono 4.2.3.4 (This is the latest binary release for Windows, you can use newer if there is one).
-- Add the "(InstallDir)\Mono\bin" to your PATH environment variable.
-- (Windows only)Install Cygwin 32-bit version using these command line parameters:
- setup-x86.exe -qnNdO -R "C:\cygwin" -s "http://cygwin.mirror.constant.com" 
-  -l "C:\cygwin\var\cache\setup" -P autoconf -P automake -P bison -P gcc-core -P gcc-g++ -P mingw64-i686-runtime 
-  -P mingw64-i686-binutils -P mingw64-i686-gcc-core -P mingw64-i686-gcc-g++ -P mingw64-i686-headers -P mingw64-i686-pthreads
-  -P mingw64-i686-windows-default-manifest -P mingw64-i686-winpthreads -P w32api-headers -P w32api-runtime 
-  -P windows-default-manifest -P libtool -P make -P python -P gettext-devel -P gettext -P intltool -P libiconv 
-  -P pkg-config -P git -P wget -P curl
-
-- Go to your mono source directory (the one retrieved when compiling the runtime) in terminal (Cygwin or native) and enter these commands in order:
- - "./autogen.sh --prefix="(OutputDir)" --with-preview=yes"" (Replace (OutputDir) with a folder where you want to output the binaries, e.g. "C:\MonoInstall")
- - "./configure --host=i686-w64-mingw32" if Cygwin, "./configure" if native
- - "make"
- - "make install"
-- Your built mono should now be output to (OutputDir) folder. (If it's not in that folder, and if using Cygwin then check your Cygwin install folder under /usr/local)
-- Copy contents of (OutputDir)/include/mono/mono-2.0/mono to (BansheeRootDir)/Dependencies/Include/Mono
-  - Make sure to modify "object.h" as you did above when building the binaries
-- Copy folder (OutputDir)/etc to (BansheeRootDir)/bin/Mono
-- Copy assembly folders (OutputDir)/lib/mono/4.0 and (OutputDir)/lib/mono/4.5 to (BansheeRootDir)/bin/Mono/lib/mono/4.0 and (BansheeRootDir)/bin/Mono/lib/mono/4.5, respectively
- - If you wish, you can clean up the assemblies within those folders are many might not be used. The minimum needed are "mscorlib.dll", "System.dll" and "System.Core.dll".
-- Copy the compiler (mcs executable) from (OutputDir)/lib/mono/4.5 to (BansheeRootDir)/bin/Mono/compiler

+ 37 - 19
Source/BansheeCore/Linux/BsLinuxFolderMonitor.cpp

@@ -307,23 +307,33 @@ namespace bs
 
 
 		if(findIter != m->monitors.end())
 		if(findIter != m->monitors.end())
 		{
 		{
-			Lock lock(m->mainMutex);
-			FolderWatchInfo* watchInfo = *findIter;
+			// Special case if this is the last monitor
+			if(m->monitors.size() == 1)
+				stopMonitorAll();
+			else
+			{
+				Lock lock(m->mainMutex);
+				FolderWatchInfo* watchInfo = *findIter;
 
 
-			watchInfo->stopMonitor();
-			bs_delete(watchInfo);
+				watchInfo->stopMonitor();
+				bs_delete(watchInfo);
 
 
-			m->monitors.erase(findIter);
+				m->monitors.erase(findIter);
+			}
 		}
 		}
-
-		if(m->monitors.size() == 0)
-			stopMonitorAll();
 	}
 	}
 
 
 	void FolderMonitor::stopMonitorAll()
 	void FolderMonitor::stopMonitorAll()
 	{
 	{
+		if(m->started)
 		{
 		{
 			Lock lock(m->mainMutex);
 			Lock lock(m->mainMutex);
+
+			// First tell the thread it's ready to be shutdown
+			m->started = false;
+
+			// Remove all watches (this will also wake up the thread). Note that at least one watch must be present otherwise
+			// the thread won't wake up (we ensure that elsewhere).
 			for (auto& watchInfo : m->monitors)
 			for (auto& watchInfo : m->monitors)
 			{
 			{
 				watchInfo->stopMonitor();
 				watchInfo->stopMonitor();
@@ -333,38 +343,40 @@ namespace bs
 			m->monitors.clear();
 			m->monitors.clear();
 		}
 		}
 
 
+		// Wait for the thread to shutdown
+		if(m->workerThread != nullptr)
+		{
+			m->workerThread->join();
+			bs_delete(m->workerThread);
+			m->workerThread = nullptr;
+		}
+
+		// Close the inotify handle
 		{
 		{
 			Lock lock(m->mainMutex);
 			Lock lock(m->mainMutex);
-			if (m->started)
+			if (m->inHandle != 0)
 			{
 			{
-				// This should trigger worker thread shut-down
 				close(m->inHandle);
 				close(m->inHandle);
 				m->inHandle = 0;
 				m->inHandle = 0;
-				m->started = false;
 			}
 			}
 		}
 		}
-
-		if(m->workerThread != nullptr)
-		{
-			m->workerThread->join();
-			bs_delete(m->workerThread);
-			m->workerThread = nullptr;
-		}
 	}
 	}
 
 
 	void FolderMonitor::workerThreadMain()
 	void FolderMonitor::workerThreadMain()
 	{
 	{
 		static const UINT32 BUFFER_SIZE = 16384;
 		static const UINT32 BUFFER_SIZE = 16384;
 
 
+		bool shouldRun;
 		INT32 watchHandle;
 		INT32 watchHandle;
 		{
 		{
 			Lock(m->mainMutex);
 			Lock(m->mainMutex);
 			watchHandle = m->inHandle;
 			watchHandle = m->inHandle;
+			shouldRun = m->started;
 		}
 		}
 
 
 		UINT8 buffer[BUFFER_SIZE];
 		UINT8 buffer[BUFFER_SIZE];
 
 
-		while(true)
+		while(shouldRun)
 		{
 		{
 			INT32 length = (INT32)read(watchHandle, buffer, sizeof(buffer));
 			INT32 length = (INT32)read(watchHandle, buffer, sizeof(buffer));
 
 
@@ -372,6 +384,12 @@ namespace bs
 			if (length < 0)
 			if (length < 0)
 				return;
 				return;
 
 
+			// Note: Must be after read, so shutdown can be started when we remove the watches (as then read() will return)
+			{
+				Lock(m->mainMutex);
+				shouldRun = m->started;
+			}
+
 			INT32 readPos = 0;
 			INT32 readPos = 0;
 			while(readPos < length)
 			while(readPos < length)
 			{
 			{

+ 7 - 0
Source/MBansheeEditor/General/EditorApplication.cs

@@ -952,6 +952,13 @@ namespace BansheeEditor
             EditorSettings.Save();
             EditorSettings.Save();
 
 
             ProjectLibrary.Refresh();
             ProjectLibrary.Refresh();
+
+            if(monitor != null)
+            {
+                monitor.Destroy();
+                monitor = null;
+            }
+
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
             monitor.OnAdded += OnAssetModified;
             monitor.OnAdded += OnAssetModified;
             monitor.OnRemoved += OnAssetModified;
             monitor.OnRemoved += OnAssetModified;

+ 4 - 0
Source/SBansheeEditor/Wrappers/BsScriptProjectLibrary.cpp

@@ -330,6 +330,10 @@ namespace bs
 		:ScriptObjectBase(instance)
 		:ScriptObjectBase(instance)
 	{ }
 	{ }
 
 
+	ScriptLibraryEntry::ScriptLibraryEntry(MonoObject* instance)
+		:ScriptObject(instance)
+	{ }
+
 	void ScriptLibraryEntry::initRuntimeData()
 	void ScriptLibraryEntry::initRuntimeData()
 	{
 	{
 		metaData.scriptClass->addInternalCall("Internal_GetPath", (void*)&ScriptLibraryEntry::internal_GetPath);
 		metaData.scriptClass->addInternalCall("Internal_GetPath", (void*)&ScriptLibraryEntry::internal_GetPath);

+ 2 - 0
Source/SBansheeEditor/Wrappers/BsScriptProjectLibrary.h

@@ -104,6 +104,8 @@ namespace bs
 	public:
 	public:
 		SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "LibraryEntry")
 		SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "LibraryEntry")
 
 
+		ScriptLibraryEntry(MonoObject* instance);
+
 	private:
 	private:
 		/************************************************************************/
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/* 								CLR HOOKS						   		*/