Browse Source

DX9, DX11 and OpenGL shader refactor done - No more separation between high and low level shaders, they're all high level now

Marko Pintera 11 years ago
parent
commit
3196cff881
62 changed files with 1370 additions and 3036 deletions
  1. 2 2
      BansheeEditor/Source/BsEditorApplication.cpp
  2. 2 6
      CamelotCore/CamelotCore.vcxproj
  3. 6 18
      CamelotCore/CamelotCore.vcxproj.filters
  4. 1 2
      CamelotCore/Include/CmApplication.h
  5. 42 9
      CamelotCore/Include/CmGpuProgram.h
  6. 56 31
      CamelotCore/Include/CmGpuProgramManager.h
  7. 0 106
      CamelotCore/Include/CmHighLevelGpuProgram.h
  8. 0 125
      CamelotCore/Include/CmHighLevelGpuProgramManager.h
  9. 2 4
      CamelotCore/Include/CmPrerequisites.h
  10. 4 4
      CamelotCore/Source/CmApplication.cpp
  11. 28 7
      CamelotCore/Source/CmGpuProgram.cpp
  12. 9 2
      CamelotCore/Source/CmGpuProgramImporter.cpp
  13. 130 12
      CamelotCore/Source/CmGpuProgramManager.cpp
  14. 0 82
      CamelotCore/Source/CmHighLevelGpuProgram.cpp
  15. 0 172
      CamelotCore/Source/CmHighLevelGpuProgramManager.cpp
  16. 1 1
      CamelotCore/Source/CmRenderSystem.cpp
  17. 1 5
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj
  18. 3 15
      CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters
  19. 83 14
      CamelotD3D11RenderSystem/Include/CmD3D11GpuProgram.h
  20. 0 19
      CamelotD3D11RenderSystem/Include/CmD3D11GpuProgramManager.h
  21. 0 78
      CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgram.h
  22. 8 7
      CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgramFactory.h
  23. 0 33
      CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgramRTTI.h
  24. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11InputLayoutManager.h
  25. 2 2
      CamelotD3D11RenderSystem/Include/CmD3D11Prerequisites.h
  26. 1 1
      CamelotD3D11RenderSystem/Include/CmD3D11RenderSystem.h
  27. 212 135
      CamelotD3D11RenderSystem/Source/CmD3D11GpuProgram.cpp
  28. 0 32
      CamelotD3D11RenderSystem/Source/CmD3D11GpuProgramManager.cpp
  29. 0 192
      CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp
  30. 28 12
      CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgramFactory.cpp
  31. 3 3
      CamelotD3D11RenderSystem/Source/CmD3D11InputLayoutManager.cpp
  32. 8 14
      CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp
  33. 1 5
      CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj
  34. 3 15
      CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj.filters
  35. 54 66
      CamelotD3D9Renderer/Include/CmD3D9GpuProgram.h
  36. 0 49
      CamelotD3D9Renderer/Include/CmD3D9GpuProgramManager.h
  37. 0 120
      CamelotD3D9Renderer/Include/CmD3D9HLSLProgram.h
  38. 14 41
      CamelotD3D9Renderer/Include/CmD3D9HLSLProgramFactory.h
  39. 0 33
      CamelotD3D9Renderer/Include/CmD3D9HLSLProgramRTTI.h
  40. 1 1
      CamelotD3D9Renderer/Include/CmD3D9Prerequisites.h
  41. 234 172
      CamelotD3D9Renderer/Source/CmD3D9GpuProgram.cpp
  42. 0 60
      CamelotD3D9Renderer/Source/CmD3D9GpuProgramManager.cpp
  43. 0 267
      CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp
  44. 33 47
      CamelotD3D9Renderer/Source/CmD3D9HLSLProgramFactory.cpp
  45. 4 9
      CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp
  46. 1 7
      CamelotGLRenderer/CamelotGLRenderer.vcxproj
  47. 66 78
      CamelotGLRenderer/CamelotGLRenderer.vcxproj.filters
  48. 0 50
      CamelotGLRenderer/Include/CmGLGpuProgramManager.h
  49. 1 1
      CamelotGLRenderer/Include/CmGLPrerequisites.h
  50. 0 1
      CamelotGLRenderer/Include/CmGLRenderSystem.h
  51. 0 33
      CamelotGLRenderer/Include/CmGLSLProgramRTTI.h
  52. 0 50
      CamelotGLRenderer/Source/CmGLGpuProgramManager.cpp
  53. 6 12
      CamelotGLRenderer/Source/CmGLRenderSystem.cpp
  54. 0 78
      CamelotGLRenderer/Source/GLSL/include/CmGLSLExtSupport.h
  55. 83 50
      CamelotGLRenderer/Source/GLSL/include/CmGLSLGpuProgram.h
  56. 0 145
      CamelotGLRenderer/Source/GLSL/include/CmGLSLProgram.h
  57. 12 43
      CamelotGLRenderer/Source/GLSL/include/CmGLSLProgramFactory.h
  58. 0 138
      CamelotGLRenderer/Source/GLSL/src/CmGLSLExtSupport.cpp
  59. 202 49
      CamelotGLRenderer/Source/GLSL/src/CmGLSLGpuProgram.cpp
  60. 0 219
      CamelotGLRenderer/Source/GLSL/src/CmGLSLProgram.cpp
  61. 16 44
      CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramFactory.cpp
  62. 5 6
      CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramPipelineManager.cpp

+ 2 - 2
BansheeEditor/Source/BsEditorApplication.cpp

@@ -172,7 +172,7 @@ namespace BansheeEngine
 			importOptions->setType(GPT_FRAGMENT_PROGRAM);
 		}
 
-		HHighLevelGpuProgram fragProgRef = Importer::instance().import(psLoc, gpuProgImportOptions);
+		HGpuProgram fragProgRef = Importer::instance().import(psLoc, gpuProgImportOptions);
 
 		gpuProgImportOptions = Importer::instance().createImportOptions(vsLoc);
 		if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
@@ -185,7 +185,7 @@ namespace BansheeEngine
 			importOptions->setType(GPT_VERTEX_PROGRAM);
 		}
 
-		HHighLevelGpuProgram vertProgRef = Importer::instance().import(vsLoc, gpuProgImportOptions);
+		HGpuProgram vertProgRef = Importer::instance().import(vsLoc, gpuProgImportOptions);
 
 		gResources().save(vertProgRef, L"C:\\vertProgCg.vprog", true);
 		gResources().unload(vertProgRef);

+ 2 - 6
CamelotCore/CamelotCore.vcxproj

@@ -338,7 +338,6 @@
     <ClInclude Include="Include\CmGpuProgramImporter.h" />
     <ClInclude Include="Include\CmGpuProgramImportOptions.h" />
     <ClInclude Include="Include\CmGpuProgramImportOptionsRTTI.h" />
-    <ClInclude Include="Include\CmGpuProgramManager.h" />
     <ClInclude Include="Include\CmGpuProgramParams.h" />
     <ClInclude Include="Include\CmGpuProgramRTTI.h" />
     <ClInclude Include="Include\CmHardwareBuffer.h" />
@@ -358,8 +357,7 @@
     <ClInclude Include="Include\CmTransientMesh.h" />
     <ClInclude Include="Include\CmUUID.h" />
     <ClInclude Include="Include\CmVertexBuffer.h" />
-    <ClInclude Include="Include\CmHighLevelGpuProgram.h" />
-    <ClInclude Include="Include\CmHighLevelGpuProgramManager.h" />
+    <ClInclude Include="Include\CmGpuProgramManager.h" />
     <ClInclude Include="Include\CmImporter.h" />
     <ClInclude Include="Include\CmInput.h" />
     <ClInclude Include="Include\CmRawInputHandler.h" />
@@ -453,7 +451,6 @@
     <ClCompile Include="Source\CmGpuProgram.cpp" />
     <ClCompile Include="Source\CmGpuProgramImporter.cpp" />
     <ClCompile Include="Source\CmGpuProgramImportOptions.cpp" />
-    <ClCompile Include="Source\CmGpuProgramManager.cpp" />
     <ClCompile Include="Source\CmGpuProgramParams.cpp" />
     <ClCompile Include="Source\CmGpuResource.cpp" />
     <ClCompile Include="Source\CmGpuResourceData.cpp" />
@@ -485,8 +482,7 @@
     <ClCompile Include="Source\CmTransientMesh.cpp" />
     <ClCompile Include="Source\CmUUID.cpp" />
     <ClCompile Include="Source\CmVertexBuffer.cpp" />
-    <ClCompile Include="Source\CmHighLevelGpuProgram.cpp" />
-    <ClCompile Include="Source\CmHighLevelGpuProgramManager.cpp" />
+    <ClCompile Include="Source\CmGpuProgramManager.cpp" />
     <ClCompile Include="Source\CmImporter.cpp" />
     <ClCompile Include="Source\CmInput.cpp" />
     <ClCompile Include="Source\CmMaterial.cpp" />

+ 6 - 18
CamelotCore/CamelotCore.vcxproj.filters

@@ -129,12 +129,6 @@
     <ClInclude Include="Include\CmRenderSystemCapabilities.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmHighLevelGpuProgramManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmHighLevelGpuProgram.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmHardwareBuffer.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
@@ -144,9 +138,6 @@
     <ClInclude Include="Include\CmGpuProgramParams.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmGpuProgramManager.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmGpuProgram.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
@@ -537,6 +528,9 @@
     <ClInclude Include="Include\CmUUID.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmGpuProgramManager.h">
+      <Filter>Header Files\RenderSystem</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmApplication.cpp">
@@ -551,21 +545,12 @@
     <ClCompile Include="Source\CmGpuProgram.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmGpuProgramManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmGpuProgramParams.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
     <ClCompile Include="Source\CmHardwareBufferManager.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmHighLevelGpuProgram.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmHighLevelGpuProgramManager.cpp">
-      <Filter>Source Files\RenderSystem</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmRenderSystem.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
@@ -845,5 +830,8 @@
     <ClCompile Include="Source\CmUUID.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmGpuProgramManager.cpp">
+      <Filter>Source Files\RenderSystem</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 1 - 2
CamelotCore/Include/CmApplication.h

@@ -2,7 +2,6 @@
 
 #include "CmPrerequisites.h"
 #include "CmCoreThreadAccessor.h"
-#include "CmHighLevelGpuProgram.h"
 #include "CmRenderWindow.h"
 #include "BsEvent.h"
 
@@ -10,7 +9,7 @@ namespace BansheeEngine
 {
 	class RenderWindow;
 	class Viewport;
-	class HighLevelGpuProgramManager;
+	class GpuProgramManager;
 }
 
 namespace BansheeEngine

+ 42 - 9
CamelotCore/Include/CmGpuProgram.h

@@ -58,12 +58,10 @@ namespace BansheeEngine
 	};
 
 	/**
-	 * @brief	Contains a low level GPU program such as vertex or fragment program.
-	 *			Internal implementation of this class is render system specific,
-	 *			but will normally store a compiled program.
+	 * @brief	Contains a GPU program such as vertex or fragment program which gets
+	 *			compiled from the provided source code.
 	 *
-	 * @note	For higher level programs see HighLevelGpuProgram.
-	 *			Core thread only.
+	 * @note	Core thread only.
 	 */
 	class CM_EXPORT GpuProgram : public Resource
 	{
@@ -91,14 +89,23 @@ namespace BansheeEngine
 		virtual const String& getEntryPoint() const { return mEntryPoint; }
 
 		/**
-		 * @brief	Returns a delegate that will be used for actually binding the program to the pipeline.
+		 * @brief	Returns whether this program can be supported on the current renderer and hardware.
 		 */
-        virtual GpuProgramPtr getBindingDelegate() { return std::static_pointer_cast<GpuProgram>(getThisPtr()); }
+        virtual bool isSupported() const;
 
 		/**
-		 * @brief	Returns whether this program can be supported on the current renderer and hardware.
+		 * @brief	Returns true if shader was successfully compiled. 
+		 *
+		 * @note	Thread safe. Only valid after core thread has initialized the program.
 		 */
-        virtual bool isSupported() const;
+		virtual bool isCompiled() const { return mIsCompiled; }
+
+		/**
+		 * @brief	Returns an error message returned by the compiler, if the compilation failed.
+		 *
+		 * @note	Thread safe. Only valid after core thread has initialized the program.
+		 */
+		virtual String getCompileErrorMessage() const { return mCompileError; }
 
 		/**
 		 * @brief	Sets whether this geometry program requires adjacency information
@@ -133,6 +140,29 @@ namespace BansheeEngine
 		*/
         virtual const String& getLanguage() const;
 
+		/**
+		 * @brief	Creates a new GPU program using the provided source code. If compilation fails or program is not supported
+		 *			"isCompiled" with return false, and you will be able to retrieve the error message via "getCompileErrorMessage".
+		 *
+		 * @param	source		Source code to compile the shader from.
+		 * @param	entryPoint	Name of the entry point function, e.g. "main".
+		 * @param	language	Language the source is written in, e.g. "hlsl" or "glsl".
+		 * @param	gptype		Type of the program, e.g. vertex or fragment.
+		 * @param	profile		Program profile specifying supported feature-set. Must match the type.
+		 * @param	includes	Optional includes to append to the source before compiling.
+		 * @param	requiresAdjacency	If true then adjacency information will be provided when rendering using this program.
+		 */
+		static HGpuProgram create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency = false);
+
+		/**
+		 * @copydoc	create
+		 *
+		 * @note	Internal method. For normal use call "create".
+		 */
+		static GpuProgramPtr _createPtr(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency = false);
+
 	protected:
 		friend class GpuProgramManager;
 
@@ -157,6 +187,9 @@ namespace BansheeEngine
 		GpuProgramProfile mProfile;
         String mSource;
 
+		bool mIsCompiled;
+		String mCompileError;
+
 		GpuParamDesc mParametersDesc;
 
 		/************************************************************************/

+ 56 - 31
CamelotCore/Include/CmGpuProgramManager.h

@@ -1,50 +1,75 @@
 #pragma once
 
 #include "CmPrerequisites.h"
+#include "CmModule.h"
 #include "CmException.h"
 #include "CmGpuProgram.h"
-#include "CmModule.h"
 
 namespace BansheeEngine 
 {
-	/**
-	 * @brief	Handles creation of GPU programs for a specific language. Program source
-	 *			will be parses and a usable GPU program which you may bind to the pipeline
-	 *			will be returned.
-	 */
+	class CM_EXPORT GpuProgramFactory
+	{
+	public:
+        GpuProgramFactory() {}
+        virtual ~GpuProgramFactory();
+		/// Get the name of the language this factory creates programs for
+		virtual const String& getLanguage(void) const = 0;
+		virtual GpuProgramPtr create(const String& source, const String& entryPoint,
+			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool requiresAdjacencyInformation) = 0;
+		virtual GpuProgramPtr create() = 0;
+	};
+
 	class CM_EXPORT GpuProgramManager : public Module<GpuProgramManager>
 	{
+	public:
+		typedef Map<String, GpuProgramFactory*> FactoryMap;
+	protected:
+		/// Factories capable of creating HighLevelGpuProgram instances
+		FactoryMap mFactories;
+
+		/// Factory for dealing with programs for languages we can't create
+		GpuProgramFactory* mNullFactory;
+
+		GpuProgramFactory* getFactory(const String& language);
 	public:
 		GpuProgramManager();
-		virtual ~GpuProgramManager();
-	
-		/**
-		 * @brief	Converts a generic GpuProgramProfile identifier into a render-system specific one.
-		 *			Obviously this depends on the currently set render system.
-		 *			Returns an empty string if conversion can't be done.
-		 */
-		virtual String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const;
-        
-		/** Create a GPU program from a string of assembly code.
-        @remarks    
-            Use this method in preference to the 'load' methods if you wish to define
-            a GpuProgram, but not load it yet; useful for saving memory.
+		~GpuProgramManager();
+		/** Add a new factory object for high-level programs of a given language. */
+		void addFactory(GpuProgramFactory* factory);
+		/** Remove a factory object for high-level programs of a given language. */
+		void removeFactory(GpuProgramFactory* factory);
+
+		/** Returns whether a given high-level language is supported. */
+		bool isLanguageSupported(const String& lang);
+
+
+        /** Create a new HighLevelGpuProgram. 
 		@par
-			The assembly code must be compatible with this manager - call the 
-			getSupportedSyntax method for details of the supported syntaxes 
-		@param name The identifying name to give this program, which can be used to
-			retrieve this program later with getByName.
-		@param groupName The name of the resource group
-		@param code A string of assembly code which will form the program to run
-		@param gptype The type of program to create.
-        @param syntaxCode The name of the syntax to be used for this program e.g. arbvp1, vs_1_1
+			This method creates a new program of the type specified as the second and third parameters.
+		@param name The identifying name of the program
+        @param groupName The name of the resource group which this program is
+            to be a member of
+		@param language Code of the language to use (e.g. "cg")
+		@param gptype The type of program to create
 		*/
-		GpuProgramPtr createProgram(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile);
+		GpuProgramPtr create(const String& source, const String& entryPoint, const String& language, 
+			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool requiresAdjacencyInformation = false);
+
+		/** Create a new HighLevelGpuProgram. 
+		@par
+			This method creates a new program of the specified language. You need to set other 
+			properties like source, entry point, type, profile manually.
+		@param language Code of the language to use (e.g. "cg")
+		*/
+		GpuProgramPtr create(const String& language);
 
-	protected:
 		/**
-		 * @brief	Internal create method that you should override in GpuProgramManager implementation for a specific language.
+		 * @brief	Creates a completely empty and uninitialized HighLevelGpuProgram.
+		 * 			Should only be used for VERY specific purposes, like deserialization,
+		 * 			as it requires additional manual initialization that is not required normally.
 		 */
-		virtual GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile) = 0;
+		GpuProgramPtr createEmpty(const String& language);
 	};
 }

+ 0 - 106
CamelotCore/Include/CmHighLevelGpuProgram.h

@@ -1,106 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __HighLevelGpuProgram_H__
-#define __HighLevelGpuProgram_H__
-
-#include "CmPrerequisites.h"
-#include "CmGpuProgram.h"
-
-namespace BansheeEngine {
-
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup Resources
-	*  @{
-	*/
-	/** Abstract base class representing a high-level program (a vertex or
-        fragment program).
-    @remarks
-        High-level programs are vertex and fragment programs written in a high-level
-        language such as Cg or HLSL, and as such do not require you to write assembler code
-        like GpuProgram does. However, the high-level program does eventually 
-        get converted (compiled) into assembler and then eventually microcode which is
-        what runs on the GPU. As well as the convenience, some high-level languages like Cg allow
-        you to write a program which will operate under both Direct3D and OpenGL, something
-        which you cannot do with just GpuProgram (which requires you to write 2 programs and
-        use each in a Technique to provide cross-API compatibility). Ogre will be creating
-        a GpuProgram for you based on the high-level program, which is compiled specifically 
-        for the API being used at the time, but this process is transparent.
-    @par
-        You cannot create high-level programs direct - use HighLevelGpuProgramManager instead.
-        Plugins can register new implementations of HighLevelGpuProgramFactory in order to add
-        support for new languages without requiring changes to the core Ogre API. To allow 
-        custom parameters to be set, this class extends StringInterface - the application
-        can query on the available custom parameters and get/set them without having to 
-        link specifically with it.
-    */
-    class CM_EXPORT HighLevelGpuProgram : public GpuProgram
-    {
-    public:
-        virtual ~HighLevelGpuProgram();
-
-        /** @copydoc GpuProgram::getBindingDelegate */
-        virtual GpuProgramPtr getBindingDelegate(void) { return mAssemblerProgram; }
-
-    protected:
-		friend class HighLevelGpuProgramManager;
-
-		/** Constructor, should be used only by factory classes. */
-		HighLevelGpuProgram(const String& source, const String& entryPoint,
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
-			bool isAdjacencyInfoRequired = false);
-
-		/**
-		 * @copydoc Resource::initialize_internal.
-		 */
-		virtual void initialize_internal();
-
-		/**
-		 * @copydoc Resource::destroy_internal.
-		 */
-		virtual void destroy_internal();
-
-        /// The underlying assembler program
-        GpuProgramPtr mAssemblerProgram;
-
-		/************************************************************************/
-		/* 								STATICS		                     		*/
-		/************************************************************************/
-	public:
-		static HHighLevelGpuProgram create(const String& source, const String& entryPoint, 
-			const String& language, GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes = nullptr);
-
-		static HighLevelGpuProgramPtr _createPtr(const String& source, const String& entryPoint, 
-			const String& language, GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes = nullptr);
-    };
-
-	/** @} */
-
-}
-#endif

+ 0 - 125
CamelotCore/Include/CmHighLevelGpuProgramManager.h

@@ -1,125 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __HighLevelGpuProgramManager_H__
-#define __HighLevelGpuProgramManager_H__
-
-#include "CmPrerequisites.h"
-#include "CmModule.h"
-#include "CmException.h"
-#include "CmHighLevelGpuProgram.h"
-
-namespace BansheeEngine {
-
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup Resources
-	*  @{
-	*/
-	/** Interface definition for factories of HighLevelGpuProgram. */
-	class CM_EXPORT HighLevelGpuProgramFactory
-	{
-	public:
-        HighLevelGpuProgramFactory() {}
-        virtual ~HighLevelGpuProgramFactory();
-		/// Get the name of the language this factory creates programs for
-		virtual const String& getLanguage(void) const = 0;
-        virtual HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes) = 0;
-		virtual HighLevelGpuProgramPtr create() = 0;
-	};
-	/** This ResourceManager manages high-level vertex and fragment programs. 
-	@remarks
-		High-level vertex and fragment programs can be used instead of assembler programs
-		as managed by GpuProgramManager; however they typically result in a GpuProgram
-		being created as a derivative of the high-level program. High-level programs are
-		easier to write, and can often be API-independent, unlike assembler programs. 
-	@par
-		This class not only manages the programs themselves, it also manages the factory
-		classes which allow the creation of high-level programs using a variety of high-level
-		syntaxes. Plugins can be created which register themselves as high-level program
-		factories and as such the engine can be extended to accept virtually any kind of
-		program provided a plugin is written.
-	*/
-	class CM_EXPORT HighLevelGpuProgramManager : public Module<HighLevelGpuProgramManager>
-	{
-	public:
-		typedef Map<String, HighLevelGpuProgramFactory*> FactoryMap;
-	protected:
-		/// Factories capable of creating HighLevelGpuProgram instances
-		FactoryMap mFactories;
-
-		/// Factory for dealing with programs for languages we can't create
-		HighLevelGpuProgramFactory* mNullFactory;
-
-		HighLevelGpuProgramFactory* getFactory(const String& language);
-	public:
-		HighLevelGpuProgramManager();
-		~HighLevelGpuProgramManager();
-		/** Add a new factory object for high-level programs of a given language. */
-		void addFactory(HighLevelGpuProgramFactory* factory);
-		/** Remove a factory object for high-level programs of a given language. */
-		void removeFactory(HighLevelGpuProgramFactory* factory);
-
-		/** Returns whether a given high-level language is supported. */
-		bool isLanguageSupported(const String& lang);
-
-
-        /** Create a new HighLevelGpuProgram. 
-		@par
-			This method creates a new program of the type specified as the second and third parameters.
-		@param name The identifying name of the program
-        @param groupName The name of the resource group which this program is
-            to be a member of
-		@param language Code of the language to use (e.g. "cg")
-		@param gptype The type of program to create
-		*/
-		HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, const String& language, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
-
-		/** Create a new HighLevelGpuProgram. 
-		@par
-			This method creates a new program of the specified language. You need to set other 
-			properties like source, entry point, type, profile manually.
-		@param language Code of the language to use (e.g. "cg")
-		*/
-		HighLevelGpuProgramPtr create(const String& language);
-
-		/**
-		 * @brief	Creates a completely empty and uninitialized HighLevelGpuProgram.
-		 * 			Should only be used for VERY specific purposes, like deserialization,
-		 * 			as it requires additional manual initialization that is not required normally.
-		 */
-		HighLevelGpuProgramPtr createEmpty(const String& language);
-	};
-	/** @} */
-	/** @} */
-
-}
-
-#endif

+ 2 - 4
CamelotCore/Include/CmPrerequisites.h

@@ -74,8 +74,8 @@ namespace BansheeEngine
 	class PixelBuffer;
 	class GpuBuffer;
 	class HighLevelGpuProgram;
-	class HighLevelGpuProgramManager;
-	class HighLevelGpuProgramFactory;
+	class GpuProgramManager;
+	class GpuProgramFactory;
     class IndexData;
     class Pass;
 	class Technique;
@@ -175,7 +175,6 @@ namespace BansheeEngine
 namespace BansheeEngine
 {
 	typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
-	typedef std::shared_ptr<HighLevelGpuProgram> HighLevelGpuProgramPtr;
 	typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
 	typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
 	typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
@@ -299,7 +298,6 @@ namespace BansheeEngine
 	typedef ResourceHandle<Texture> HTexture;
 	typedef ResourceHandle<Mesh> HMesh;
 	typedef ResourceHandle<GpuProgram> HGpuProgram;
-	typedef ResourceHandle<HighLevelGpuProgram> HHighLevelGpuProgram;
 	typedef ResourceHandle<Material> HMaterial;
 	typedef ResourceHandle<SamplerState> HSamplerState;
 	typedef ResourceHandle<RasterizerState> HRasterizerState;

+ 4 - 4
CamelotCore/Source/CmApplication.cpp

@@ -8,8 +8,7 @@
 #include "CmRenderWindow.h"
 #include "CmViewport.h"
 #include "CmVector2.h"
-#include "CmHighLevelGpuProgram.h"
-#include "CmHighLevelGpuProgramManager.h"
+#include "CmGpuProgram.h"
 #include "CmCoreObjectManager.h"
 #include "CmGameObjectManager.h"
 #include "CmDynLib.h"
@@ -22,6 +21,7 @@
 #include "CmTime.h"
 #include "CmInput.h"
 #include "CmRendererManager.h"
+#include "CmGpuProgramManager.h"
 #include "CmMeshManager.h"
 #include "CmMaterialManager.h"
 #include "CmFontManager.h"
@@ -71,7 +71,7 @@ namespace BansheeEngine
 		CoreObjectManager::startUp(cm_new<CoreObjectManager>());
 		GameObjectManager::startUp(cm_new<GameObjectManager>());
 		Resources::startUp(cm_new<Resources>());
-		HighLevelGpuProgramManager::startUp(cm_new<HighLevelGpuProgramManager>());
+		GpuProgramManager::startUp(cm_new<GpuProgramManager>());
 
 		CoreThread::startUp(cm_new<CoreThread>());
 		RenderSystemManager::startUp(cm_new<RenderSystemManager>());
@@ -193,7 +193,7 @@ namespace BansheeEngine
 		CoreThread::shutDown();
 		Input::shutDown();
 
-		HighLevelGpuProgramManager::shutDown();
+		GpuProgramManager::shutDown();
 		Resources::shutDown();
 		GameObjectManager::shutDown();
 		CoreObjectManager::shutDown(); // Must shut down before DynLibManager to ensure all objects are destroyed before unloading their libraries

+ 28 - 7
CamelotCore/Source/CmGpuProgram.cpp

@@ -1,5 +1,4 @@
 #include "CmGpuProgram.h"
-#include "CmHighLevelGpuProgram.h"
 #include "CmVector3.h"
 #include "CmVector4.h"
 #include "CmRenderSystemCapabilities.h"
@@ -8,13 +7,15 @@
 #include "CmAsyncOp.h"
 #include "CmGpuParams.h"
 #include "CmGpuProgInclude.h"
+#include "CmGpuProgramManager.h"
+#include "CmResources.h"
 #include "CmGpuProgramRTTI.h"
 
 namespace BansheeEngine
 {
     GpuProgram::GpuProgram(const String& source, const String& entryPoint, 
 		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired) 
-        :mEntryPoint(entryPoint), mType(gptype),
+		:mEntryPoint(entryPoint), mType(gptype), mIsCompiled(false),
 		mProfile(profile), mNeedsAdjacencyInfo(isAdjacencyInfoRequired)
     {
 		if(includes != nullptr)
@@ -44,26 +45,46 @@ namespace BansheeEngine
 
     bool GpuProgram::isSupported() const
     {
-		return false;
+		if (!isRequiredCapabilitiesSupported())
+			return false;
+
+		RenderSystem* rs = BansheeEngine::RenderSystem::instancePtr();
+		String profile = rs->getCapabilities()->gpuProgProfileToRSSpecificProfile(mProfile);
+
+		return rs->getCapabilities()->isShaderProfileSupported(profile);
     }
 
-	bool GpuProgram::isRequiredCapabilitiesSupported(void) const
+	bool GpuProgram::isRequiredCapabilitiesSupported() const
 	{
 		return true;
 	}
 
-	GpuParamsPtr GpuProgram::createParameters(void)
+	GpuParamsPtr GpuProgram::createParameters()
 	{
 		return cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc), false);
 	}
 
-    const String& GpuProgram::getLanguage(void) const
+    const String& GpuProgram::getLanguage() const
     {
-        static const String language = "asm";
+        static const String language = "null";
 
         return language;
     }
 
+	HGpuProgram GpuProgram::create(const String& source, const String& entryPoint, const String& language, GpuProgramType gptype,
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency)
+	{
+		GpuProgramPtr programPtr = _createPtr(source, entryPoint, language, gptype, profile, includes);
+
+		return static_resource_cast<GpuProgram>(gResources().createResourceHandle(programPtr));
+	}
+
+	GpuProgramPtr GpuProgram::_createPtr(const String& source, const String& entryPoint,
+		const String& language, GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency)
+	{
+		return GpuProgramManager::instance().create(source, entryPoint, language, gptype, profile, includes);
+	}
+
 	/************************************************************************/
 	/* 								SERIALIZATION                      		*/
 	/************************************************************************/

+ 9 - 2
CamelotCore/Source/CmGpuProgramImporter.cpp

@@ -3,7 +3,8 @@
 #include "CmDataStream.h"
 #include "CmFileSystem.h"
 #include "CmGpuProgramImportOptions.h"
-#include "CmHighLevelGpuProgram.h"
+#include "CmGpuProgram.h"
+#include "CmDebug.h"
 
 namespace BansheeEngine
 {
@@ -37,9 +38,15 @@ namespace BansheeEngine
 		GpuProgramType gptype = gpuProgImportOptions->getType();
 		Vector<HGpuProgInclude> includes = gpuProgImportOptions->getIncludes();
 
-		HighLevelGpuProgramPtr gpuProgram = HighLevelGpuProgram::_createPtr(shaderSource, entryPoint, language, gptype, profile, &includes);
+		GpuProgramPtr gpuProgram = GpuProgram::_createPtr(shaderSource, entryPoint, language, gptype, profile, &includes);
 		gpuProgram->synchronize();
 
+		if (!gpuProgram->isCompiled())
+		{
+			LOGERR("Failed compiling GPU program: " + filePath.toString() + ". Error: " + gpuProgram->getCompileErrorMessage());
+			// TODO - Return some dummy program here?
+		}
+
 		WString fileName = filePath.getWFilename(false);
 		gpuProgram->setName(toString(fileName));
 

+ 130 - 12
CamelotCore/Source/CmGpuProgramManager.cpp

@@ -3,28 +3,146 @@
 
 namespace BansheeEngine 
 {
+	String sNullLang = "null";
+	class NullProgram : public GpuProgram
+	{
+	protected:
+		/** Internal load implementation, must be implemented by subclasses.
+		*/
+		void loadFromSource(void) {}
+		/// Populate the passed parameters with name->index map, must be overridden
+		void populateParameterNames(GpuProgramParametersSharedPtr params)
+		{
+			// Skip the normal implementation
+			// Ensure we don't complain about missing parameter names
+			params->setIgnoreMissingParams(true);
+
+		}
+		void buildConstantDefinitions() const
+		{
+			// do nothing
+		}
+
+	public:
+		NullProgram()
+			: GpuProgram("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr){}
+		~NullProgram() {}
+		/// Overridden from GpuProgram - never supported
+		bool isSupported(void) const { return false; }
+		/// Overridden from GpuProgram
+		const String& getLanguage(void) const { return sNullLang; }
+
+		/// Overridden from StringInterface
+		bool setParameter(const String& name, const String& value)
+		{
+			// always silently ignore all parameters so as not to report errors on
+			// unsupported platforms
+			return true;
+		}
+	};
+
+	class NullProgramFactory : public GpuProgramFactory
+	{
+	public:
+		NullProgramFactory() {}
+		~NullProgramFactory() {}
+		/// Get the name of the language this factory creates programs for
+		const String& getLanguage(void) const 
+		{ 
+			return sNullLang;
+		}
+		GpuProgramPtr create(const String& source, const String& entryPoint,
+			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, 
+			bool requiresAdjacencyInformation)
+		{
+			return cm_core_ptr<NullProgram, PoolAlloc>();
+		}
+		GpuProgramPtr create()
+		{
+			return cm_core_ptr<NullProgram, PoolAlloc>();
+		}
+	};
+
 	GpuProgramManager::GpuProgramManager()
-	{ }
+	{
+		mNullFactory = cm_new<NullProgramFactory>();
+		addFactory(mNullFactory);
+	}
 
 	GpuProgramManager::~GpuProgramManager()
-	{ }
+	{
+		cm_delete((NullProgramFactory*)mNullFactory);
+	}
+
+	void GpuProgramManager::addFactory(GpuProgramFactory* factory)
+	{
+		// deliberately allow later plugins to override earlier ones
+		mFactories[factory->getLanguage()] = factory;
+	}
 
-	GpuProgramPtr GpuProgramManager::createProgram(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile)
+    void GpuProgramManager::removeFactory(GpuProgramFactory* factory)
     {
-		GpuProgramPtr prg = create(source, entryPoint, gptype, profile);
-		prg->_setThisPtr(prg);
+        // Remove only if equal to registered one, since it might overridden
+        // by other plugins
+        FactoryMap::iterator it = mFactories.find(factory->getLanguage());
+        if (it != mFactories.end() && it->second == factory)
+        {
+            mFactories.erase(it);
+        }
+    }
+
+	GpuProgramFactory* GpuProgramManager::getFactory(const String& language)
+	{
+		FactoryMap::iterator i = mFactories.find(language);
+
+		if (i == mFactories.end())
+		{
+			// use the null factory to create programs that will never be supported
+			i = mFactories.find(sNullLang);
+		}
+		return i->second;
+	}
+
+	bool GpuProgramManager::isLanguageSupported(const String& lang)
+	{
+		FactoryMap::iterator i = mFactories.find(lang);
+
+		return i != mFactories.end();
+
+	}
 
-		// TODO: GPU programs get initialized by their parent HighLevelGpuProgram. I might handle that more intuitively later but
-		// it works just fine as it is
-		//prg->initialize();
+    GpuProgramPtr GpuProgramManager::create(const String& source, const String& entryPoint, const String& language, 
+		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+		bool requiresAdjacencyInformation)
+    {
+		GpuProgramFactory* factory = getFactory(language);
+		GpuProgramPtr ret = factory->create(source, entryPoint, gptype, profile, includes, requiresAdjacencyInformation);
+		ret->_setThisPtr(ret);
+		ret->initialize();
 
-        return prg;
+        return ret;
     }
 
-	String GpuProgramManager::gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const
+	GpuProgramPtr GpuProgramManager::create(const String& language)
+	{
+		GpuProgramFactory* factory = getFactory(language);
+		GpuProgramPtr ret = factory->create();
+		ret->_setThisPtr(ret);
+		ret->initialize();
+
+		return ret;
+	}
+
+	GpuProgramPtr GpuProgramManager::createEmpty(const String& language)
 	{
-		RenderSystem* rs = BansheeEngine::RenderSystem::instancePtr();
+		GpuProgramFactory* factory = getFactory(language);
+		GpuProgramPtr ret = factory->create();
+		ret->_setThisPtr(ret);
 
-		return  rs->getCapabilities()->gpuProgProfileToRSSpecificProfile(gpuProgProfile);
+		return ret;
 	}
+
+    GpuProgramFactory::~GpuProgramFactory() 
+    {
+    }
 }

+ 0 - 82
CamelotCore/Source/CmHighLevelGpuProgram.cpp

@@ -1,82 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmHighLevelGpuProgram.h"
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmException.h"
-#include "CmCoreThread.h"
-#include "CmAsyncOp.h"
-#include "CmResources.h"
-
-namespace BansheeEngine
-{
-	HighLevelGpuProgram::HighLevelGpuProgram(const String& source, const String& entryPoint, 
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
-        : GpuProgram(source, entryPoint, gptype, profile, includes, isAdjacencyInfoRequired), 
-        mAssemblerProgram(nullptr)
-    {
-    }
-
-	HighLevelGpuProgram::~HighLevelGpuProgram()
-	{
-
-	}
-
-    void HighLevelGpuProgram::initialize_internal()
-    {
-		if (isSupported())
-		{
-			if (mAssemblerProgram != nullptr && mAssemblerProgram.get() != this)
-			{
-				mAssemblerProgram->initialize();
-			}
-		}
-
-		GpuProgram::initialize_internal();
-    }
-
-    void HighLevelGpuProgram::destroy_internal()
-    {   
-        mAssemblerProgram = nullptr;
-
-		GpuProgram::destroy_internal();
-    }
-
-	HHighLevelGpuProgram HighLevelGpuProgram::create(const String& source, const String& entryPoint, 
-		const String& language, GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes)
-	{
-		HighLevelGpuProgramPtr programPtr = _createPtr(source, entryPoint, language, gptype, profile, includes);
-
-		return static_resource_cast<HighLevelGpuProgram>(gResources().createResourceHandle(programPtr));
-	}
-
-	HighLevelGpuProgramPtr HighLevelGpuProgram::_createPtr(const String& source, const String& entryPoint, 
-		const String& language, GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes)
-	{
-		return HighLevelGpuProgramManager::instance().create(source, entryPoint, language, gptype, profile, includes);
-	}
-}

+ 0 - 172
CamelotCore/Source/CmHighLevelGpuProgramManager.cpp

@@ -1,172 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmRenderSystem.h"
-
-namespace BansheeEngine {
-
-	String sNullLang = "null";
-	class NullProgram : public HighLevelGpuProgram
-	{
-	protected:
-		/** Internal load implementation, must be implemented by subclasses.
-		*/
-		void loadFromSource(void) {}
-		/// Populate the passed parameters with name->index map, must be overridden
-		void populateParameterNames(GpuProgramParametersSharedPtr params)
-		{
-			// Skip the normal implementation
-			// Ensure we don't complain about missing parameter names
-			params->setIgnoreMissingParams(true);
-
-		}
-		void buildConstantDefinitions() const
-		{
-			// do nothing
-		}
-	public:
-		NullProgram()
-			: HighLevelGpuProgram("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr){}
-		~NullProgram() {}
-		/// Overridden from GpuProgram - never supported
-		bool isSupported(void) const { return false; }
-		/// Overridden from GpuProgram
-		const String& getLanguage(void) const { return sNullLang; }
-
-		/// Overridden from StringInterface
-		bool setParameter(const String& name, const String& value)
-		{
-			// always silently ignore all parameters so as not to report errors on
-			// unsupported platforms
-			return true;
-		}
-
-	};
-	class NullProgramFactory : public HighLevelGpuProgramFactory
-	{
-	public:
-		NullProgramFactory() {}
-		~NullProgramFactory() {}
-		/// Get the name of the language this factory creates programs for
-		const String& getLanguage(void) const 
-		{ 
-			return sNullLang;
-		}
-		HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes)
-		{
-			return cm_core_ptr<NullProgram, PoolAlloc>();
-		}
-		HighLevelGpuProgramPtr create()
-		{
-			return cm_core_ptr<NullProgram, PoolAlloc>();
-		}
-	};
-	//-----------------------------------------------------------------------
-	HighLevelGpuProgramManager::HighLevelGpuProgramManager()
-	{
-		mNullFactory = cm_new<NullProgramFactory>();
-		addFactory(mNullFactory);
-	}
-	//-----------------------------------------------------------------------
-	HighLevelGpuProgramManager::~HighLevelGpuProgramManager()
-	{
-		cm_delete((NullProgramFactory*)mNullFactory);
-	}
-    //---------------------------------------------------------------------------
-	void HighLevelGpuProgramManager::addFactory(HighLevelGpuProgramFactory* factory)
-	{
-		// deliberately allow later plugins to override earlier ones
-		mFactories[factory->getLanguage()] = factory;
-	}
-    //---------------------------------------------------------------------------
-    void HighLevelGpuProgramManager::removeFactory(HighLevelGpuProgramFactory* factory)
-    {
-        // Remove only if equal to registered one, since it might overridden
-        // by other plugins
-        FactoryMap::iterator it = mFactories.find(factory->getLanguage());
-        if (it != mFactories.end() && it->second == factory)
-        {
-            mFactories.erase(it);
-        }
-    }
-    //---------------------------------------------------------------------------
-	HighLevelGpuProgramFactory* HighLevelGpuProgramManager::getFactory(const String& language)
-	{
-		FactoryMap::iterator i = mFactories.find(language);
-
-		if (i == mFactories.end())
-		{
-			// use the null factory to create programs that will never be supported
-			i = mFactories.find(sNullLang);
-		}
-		return i->second;
-	}
-	//---------------------------------------------------------------------
-	bool HighLevelGpuProgramManager::isLanguageSupported(const String& lang)
-	{
-		FactoryMap::iterator i = mFactories.find(lang);
-
-		return i != mFactories.end();
-
-	}
-    //---------------------------------------------------------------------------
-    HighLevelGpuProgramPtr HighLevelGpuProgramManager::create(const String& source, const String& entryPoint, const String& language, 
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes)
-    {
-		HighLevelGpuProgramFactory* factory = getFactory(language);
-        HighLevelGpuProgramPtr ret = factory->create(source, entryPoint, gptype, profile, includes);
-		ret->_setThisPtr(ret);
-		ret->initialize();
-
-        return ret;
-    }
-	//---------------------------------------------------------------------------
-	HighLevelGpuProgramPtr HighLevelGpuProgramManager::create(const String& language)
-	{
-		HighLevelGpuProgramFactory* factory = getFactory(language);
-		HighLevelGpuProgramPtr ret = factory->create();
-		ret->_setThisPtr(ret);
-		ret->initialize();
-
-		return ret;
-	}
-	//---------------------------------------------------------------------------
-	HighLevelGpuProgramPtr HighLevelGpuProgramManager::createEmpty(const String& language)
-	{
-		HighLevelGpuProgramFactory* factory = getFactory(language);
-		HighLevelGpuProgramPtr ret = factory->create();
-		ret->_setThisPtr(ret);
-
-		return ret;
-	}
-    //---------------------------------------------------------------------------
-    HighLevelGpuProgramFactory::~HighLevelGpuProgramFactory() 
-    {
-    }
-}

+ 1 - 1
CamelotCore/Source/CmRenderSystem.cpp

@@ -125,7 +125,7 @@ namespace BansheeEngine {
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
-		switch(prg->getBindingDelegate()->getType())
+		switch(prg->getType())
 		{
 		case GPT_VERTEX_PROGRAM:
 			if (!mVertexProgramBound && !mClipPlanes.empty())

+ 1 - 5
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj

@@ -242,13 +242,11 @@
     <ClInclude Include="Include\CmD3D11Driver.h" />
     <ClInclude Include="Include\CmD3D11DriverList.h" />
     <ClInclude Include="Include\CmD3D11GpuProgram.h" />
-    <ClInclude Include="Include\CmD3D11GpuProgramManager.h" />
     <ClInclude Include="Include\CmD3D11HardwareBuffer.h" />
     <ClInclude Include="Include\CmD3D11HLSLParamParser.h" />
-    <ClInclude Include="Include\CmD3D11HLSLProgram.h" />
     <ClInclude Include="Include\CmD3D11IndexBuffer.h" />
     <ClInclude Include="Include\CmD3D11HLSLProgramFactory.h" />
-    <ClInclude Include="Include\CmD3D11HLSLProgramRTTI.h" />
+    <ClInclude Include="Include\CmD3D11GpuProgramRTTI.h" />
     <ClInclude Include="Include\CmD3D11Mappings.h" />
     <ClInclude Include="Include\CmD3D11MultiRenderTexture.h" />
     <ClInclude Include="Include\CmD3D11GpuParamBlockBuffer.h" />
@@ -283,11 +281,9 @@
     <ClCompile Include="Source\CmD3D11GpuBufferView.cpp" />
     <ClCompile Include="Source\CmD3D11GpuParamBlockBuffer.cpp" />
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp" />
-    <ClCompile Include="Source\CmD3D11GpuProgramManager.cpp" />
     <ClCompile Include="Source\CmD3D11HardwareBuffer.cpp" />
     <ClCompile Include="Source\CmD3D11HardwareBufferManager.cpp" />
     <ClCompile Include="Source\CmD3D11HLSLParamParser.cpp" />
-    <ClCompile Include="Source\CmD3D11HLSLProgram.cpp" />
     <ClCompile Include="Source\CmD3D11IndexBuffer.cpp" />
     <ClCompile Include="Source\CmD3D11HLSLProgramFactory.cpp" />
     <ClCompile Include="Source\CmD3D11InputLayoutManager.cpp" />

+ 3 - 15
CamelotD3D11RenderSystem/CamelotD3D11RenderSystem.vcxproj.filters

@@ -42,12 +42,6 @@
     <ClInclude Include="Include\CmD3D11DriverList.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D11GpuProgramManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmD3D11HLSLProgram.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D11HardwareBuffer.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -75,9 +69,6 @@
     <ClInclude Include="Include\CmD3D11RenderSystemFactory.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D11HLSLProgramRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D11RenderStateManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -135,6 +126,9 @@
     <ClInclude Include="Include\CmD3D11TimerQuery.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmD3D11GpuProgramRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmD3D11GpuProgram.cpp">
@@ -158,12 +152,6 @@
     <ClCompile Include="Source\CmD3D11DriverList.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmD3D11GpuProgramManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmD3D11HLSLProgram.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmD3D11HardwareBuffer.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>

+ 83 - 14
CamelotD3D11RenderSystem/Include/CmD3D11GpuProgram.h

@@ -7,17 +7,74 @@ namespace BansheeEngine
 {
 	class CM_D3D11_EXPORT D3D11GpuProgram : public GpuProgram
 	{
+		static UINT32 GlobalProgramId;
+
 	public:
 		virtual ~D3D11GpuProgram();
 
-		bool isSupported() const;
+		const String& getLanguage() const;
+
+		GpuParamsPtr createParameters();
+
+		/** Sets whether matrix packing in column-major order. */
+		void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
+		/** Gets whether matrix packed in column-major order. */
+		bool getColumnMajorMatrices() const { return mColumnMajorMatrices; }
+		/** Sets whether backwards compatibility is enabled. */
+		void setEnableBackwardsCompatibility(bool enableBackwardsCompatibility) { mEnableBackwardsCompatibility = enableBackwardsCompatibility; }
+		/** Gets whether backwards compatibility is enabled. */
+		bool getEnableBackwardsCompatibility() const { return mEnableBackwardsCompatibility; }
+
+		const HLSLMicroCode& getMicroCode() const { return mMicrocode; }
+
+		VertexDeclarationPtr getInputDeclaration() const { return mInputDeclaration; }
+		UINT32 getProgramId() const { return mProgramId; }
+
 	protected:
-		D3D11GpuProgram(GpuProgramType type, GpuProgramProfile profile);
+		D3D11GpuProgram(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired);
+
+		/**
+		* @copydoc GpuProgram::initialize_internal()
+		*/
+		void initialize_internal();
+
+		/**
+		* @copydoc GpuProgram::destroy_internal()
+		*/
+		void destroy_internal();
 
 		/**
 		 * @brief	Loads shader from microcode.
 		 */
 		virtual void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode) = 0;
+
+		/**
+		 * @brief	Compiles the shader from source and generates the microcode.
+		 */
+		ID3DBlob* compileMicrocode(const String& profile);
+
+		/**
+		 * @brief	Reflects the microcode and extracts input/output parameters, and constant
+		 * 			buffer structures used by the program.
+		 */
+		void populateParametersAndConstants(ID3DBlob* microcode);
+
+	protected:
+		bool mColumnMajorMatrices;
+		bool mEnableBackwardsCompatibility;
+		UINT32 mProgramId;
+
+		HLSLMicroCode mMicrocode;
+		VertexDeclarationPtr mInputDeclaration;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class D3D11GpuProgramRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
 	};
 
 	class CM_D3D11_EXPORT D3D11GpuVertexProgram : public D3D11GpuProgram
@@ -28,9 +85,11 @@ namespace BansheeEngine
 		ID3D11VertexShader* getVertexShader() const;
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	protected:
-		friend class D3D11GpuProgramManager;
+		friend class D3D11HLSLProgramFactory;
 
-		D3D11GpuVertexProgram(GpuProgramProfile profile);
+		D3D11GpuVertexProgram(const String& source, const String& entryPoint,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool isAdjacencyInfoRequired);
 
 		/**
 		 * @copydoc GpuProgram::destroy_internal().
@@ -49,9 +108,11 @@ namespace BansheeEngine
 		ID3D11PixelShader* getPixelShader() const;
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	protected:
-		friend class D3D11GpuProgramManager;
+		friend class D3D11HLSLProgramFactory;
 
-		D3D11GpuFragmentProgram(GpuProgramProfile profile);
+		D3D11GpuFragmentProgram(const String& source, const String& entryPoint,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool isAdjacencyInfoRequired);
 
 		/**
 		 * @copydoc GpuProgram::destroy_internal().
@@ -69,9 +130,11 @@ namespace BansheeEngine
 		ID3D11DomainShader* getDomainShader() const;
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	protected:
-		friend class D3D11GpuProgramManager;
+		friend class D3D11HLSLProgramFactory;
 
-		D3D11GpuDomainProgram(GpuProgramProfile profile);
+		D3D11GpuDomainProgram(const String& source, const String& entryPoint,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool isAdjacencyInfoRequired);
 
 		/**
 		 * @copydoc GpuProgram::destroy_internal().
@@ -90,9 +153,11 @@ namespace BansheeEngine
 		ID3D11HullShader* getHullShader() const;
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 	protected:
-		friend class D3D11GpuProgramManager;
+		friend class D3D11HLSLProgramFactory;
 
-		D3D11GpuHullProgram(GpuProgramProfile profile);
+		D3D11GpuHullProgram(const String& source, const String& entryPoint,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool isAdjacencyInfoRequired);
 
 		/**
 		 * @copydoc GpuProgram::destroy_internal().
@@ -112,9 +177,11 @@ namespace BansheeEngine
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 
 	protected:
-		friend class D3D11GpuProgramManager;
+		friend class D3D11HLSLProgramFactory;
 
-		D3D11GpuGeometryProgram(GpuProgramProfile profile);
+		D3D11GpuGeometryProgram(const String& source, const String& entryPoint,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool isAdjacencyInfoRequired);
 
 		/**
 		 * @copydoc GpuProgram::destroy_internal().
@@ -134,9 +201,11 @@ namespace BansheeEngine
 		void loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode);
 
 	protected:
-		friend class D3D11GpuProgramManager;
+		friend class D3D11HLSLProgramFactory;
 
-		D3D11GpuComputeProgram(GpuProgramProfile profile);
+		D3D11GpuComputeProgram(const String& source, const String& entryPoint,
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
+			bool isAdjacencyInfoRequired);
 
 		/**
 		 * @copydoc GpuProgram::destroy_internal().

+ 0 - 19
CamelotD3D11RenderSystem/Include/CmD3D11GpuProgramManager.h

@@ -1,19 +0,0 @@
-#pragma once
-
-#include "CmD3D11Prerequisites.h"
-#include "CmGpuProgramManager.h"
-
-namespace BansheeEngine
-{
-	class D3D11GpuProgramManager : public GpuProgramManager
-	{
-	public:
-		D3D11GpuProgramManager(D3D11Device& device);
-		~D3D11GpuProgramManager();
-
-	protected:
-		D3D11Device& mDevice;
-		
-		GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile);
-	};
-}

+ 0 - 78
CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgram.h

@@ -1,78 +0,0 @@
-#pragma once
-
-#include "CmD3D11Prerequisites.h"
-#include "CmHighLevelGpuProgram.h"
-
-namespace BansheeEngine
-{
-	class D3D11HLSLProgram : public HighLevelGpuProgram
-	{
-		static UINT32 globalProgramId;
-
-	public:
-		~D3D11HLSLProgram();
-
-		const String& getLanguage() const;
-		bool isSupported() const;
-
-		GpuParamsPtr createParameters();
-
-		/** Sets whether matrix packing in column-major order. */ 
-		void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
-		/** Gets whether matrix packed in column-major order. */
-		bool getColumnMajorMatrices() const { return mColumnMajorMatrices; }
-		/** Sets whether backwards compatibility is enabled. */ 
-		void setEnableBackwardsCompatibility(bool enableBackwardsCompatibility) { mEnableBackwardsCompatibility = enableBackwardsCompatibility; }
-		/** Gets whether backwards compatibility is enabled. */
-		bool getEnableBackwardsCompatibility() const { return mEnableBackwardsCompatibility; }
-
-		const HLSLMicroCode& getMicroCode() const { return mMicrocode; }
-
-		VertexDeclarationPtr getInputDeclaration() const { return mInputDeclaration; }
-		UINT32 getProgramId() const { return mProgramId; }
-
-	protected:
-		friend class D3D11HLSLProgramFactory;
-
-		D3D11HLSLProgram(const String& source, const String& entryPoint,
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, 
-			bool isAdjacencyInfoRequired = false);
-
-        /**
-         * @copydoc HighLevelGpuProgram::initialize_internal()
-         */
-        void initialize_internal();
-
-        /**
-         * @copydoc HighLevelGpuProgram::destroy_internal()
-         */
-        void destroy_internal();
-
-	private:
-		bool mColumnMajorMatrices;
-		bool mEnableBackwardsCompatibility;
-		UINT32 mProgramId;
-
-		HLSLMicroCode mMicrocode;
-		VertexDeclarationPtr mInputDeclaration;
-
-		/**
-		 * @brief	Compiles the shader from source and generates the microcode.
-		 */
-		ID3DBlob* compileMicrocode(const String& profile);
-
-		/**
-		 * @brief	Reflects the microcode and extracts input/output parameters, and constant
-		 * 			buffer structures used by the program.
-		 */
-		void populateParametersAndConstants(ID3DBlob* microcode);
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class D3D11HLSLProgramRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-	};
-}

+ 8 - 7
CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgramFactory.h

@@ -1,21 +1,22 @@
 #pragma once
 
 #include "CmD3D11Prerequisites.h"
-#include "CmHighLevelGpuProgramManager.h"
+#include "CmGpuProgramManager.h"
 
 namespace BansheeEngine
 {
-	class CM_D3D11_EXPORT D3D11HLSLProgramFactory : public HighLevelGpuProgramFactory
+	class CM_D3D11_EXPORT D3D11HLSLProgramFactory : public GpuProgramFactory
 	{
-	protected:
-		static String sLanguageName;
 	public:
 		D3D11HLSLProgramFactory();
 		~D3D11HLSLProgramFactory();
 
 		const String& getLanguage(void) const;
-		HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
-			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
-		HighLevelGpuProgramPtr create();
+		GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requireAdjacencyInfo);
+		GpuProgramPtr create();
+
+	protected:
+		static const String LANGUAGE_NAME;
 	};
 }

+ 0 - 33
CamelotD3D11RenderSystem/Include/CmD3D11HLSLProgramRTTI.h

@@ -1,33 +0,0 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmHighLevelGpuProgram.h"
-#include "CmD3D11HLSLProgram.h"
-
-namespace BansheeEngine
-{
-	class CM_D3D11_EXPORT D3D11HLSLProgramRTTI : public RTTIType<D3D11HLSLProgram, HighLevelGpuProgram, D3D11HLSLProgramRTTI>
-	{
-	public:
-		D3D11HLSLProgramRTTI()
-		{ }
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "D3D11HLSLProgram";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_D3D11_HLSLProgram;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return HighLevelGpuProgramManager::instance().createEmpty("hlsl");
-		}
-	};
-}

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11InputLayoutManager.h

@@ -49,7 +49,7 @@ namespace BansheeEngine
 		 *			Error may be thrown if the vertex buffer doesn't provide all the necessary data.
 		 *			(TODO: Depends on how the driver handles missing data)
 		 */
-		ID3D11InputLayout* retrieveInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11HLSLProgram& vertexProgram);
+		ID3D11InputLayout* retrieveInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgram& vertexProgram);
 
 	private:
 		static const int DECLARATION_BUFFER_SIZE = 1024;
@@ -60,7 +60,7 @@ namespace BansheeEngine
 		bool mWarningShown;
 		UINT32 mLastUsedCounter;
 
-		void addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11HLSLProgram& vertexProgram);
+		void addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgram& vertexProgram);
 		void removeLeastUsed();
 
 		bool areCompatible(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl);

+ 2 - 2
CamelotD3D11RenderSystem/Include/CmD3D11Prerequisites.h

@@ -56,7 +56,7 @@ namespace BansheeEngine
 
 	enum TypeID_D3D11
 	{
-		TID_D3D11_HLSLProgram = 12000
+		TID_D3D11_GpuProgram = 12000
 	};
 
 	typedef Vector<char*> HLSLMicroCode;
@@ -71,7 +71,7 @@ namespace BansheeEngine
 	typedef std::shared_ptr<D3D11SamplerState> D3D11SamplerStatePtr;
 	typedef std::shared_ptr<D3D11DepthStencilState> D3D11DepthStencilStatePtr;
 	typedef std::shared_ptr<D3D11RenderWindow> D3D11RenderWindowPtr;
-	typedef std::shared_ptr<D3D11HLSLProgram> D3D11HLSLProgramPtr;
+	typedef std::shared_ptr<D3D11GpuProgram> D3D11GpuProgramPtr;
 
     //-------------------------------------------
 	// Windows setttings

+ 1 - 1
CamelotD3D11RenderSystem/Include/CmD3D11RenderSystem.h

@@ -122,7 +122,7 @@ namespace BansheeEngine
 		D3D11_RECT			mScissorRect;
 
 		VertexDeclarationPtr mActiveVertexDeclaration;
-		D3D11HLSLProgramPtr	 mActiveVertexShader;
+		D3D11GpuProgramPtr	 mActiveVertexShader;
 
 		/**
 		 * @brief	Creates or retrieves a proper input layout depending on the currently set vertex shader

+ 212 - 135
CamelotD3D11RenderSystem/Source/CmD3D11GpuProgram.cpp

@@ -2,13 +2,21 @@
 #include "CmD3D11Device.h"
 #include "CmException.h"
 #include "CmDebug.h"
-#include "CmRenderSystem.h"
+#include "CmGpuParams.h"
+#include "CmD3D11RenderSystem.h"
 #include "CmGpuProgramManager.h"
+#include "CmHardwareBufferManager.h"
+#include "CmD3D11HLSLParamParser.h"
+#include "CmD3D11GpuProgramRTTI.h"
 
 namespace BansheeEngine
 {
-	D3D11GpuProgram::D3D11GpuProgram(GpuProgramType type, GpuProgramProfile profile)
-		: GpuProgram("", "", type, profile, nullptr)
+	UINT32 D3D11GpuProgram::GlobalProgramId = 0;
+
+	D3D11GpuProgram::D3D11GpuProgram(const String& source, const String& entryPoint, GpuProgramType gptype, 
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: GpuProgram(source, entryPoint, gptype, profile, includes, isAdjacencyInfoRequired),
+		mColumnMajorMatrices(true), mEnableBackwardsCompatibility(false), mProgramId(0)
 	{
 
 	}
@@ -18,19 +26,142 @@ namespace BansheeEngine
 
 	}
 
-	bool D3D11GpuProgram::isSupported() const
+	void D3D11GpuProgram::initialize_internal()
 	{
-		if (!isRequiredCapabilitiesSupported())
-			return false;
+		if (!isSupported())
+		{
+			mIsCompiled = false;
+			mCompileError = "Specified program is not supported by the current render system.";
+
+			return;
+		}
+
+		D3D11RenderSystem* rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
+		String hlslProfile = rs->getCapabilities()->gpuProgProfileToRSSpecificProfile(mProfile);
 
-		RenderSystem* rs = BansheeEngine::RenderSystem::instancePtr();
-		String hlslProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
+		ID3DBlob* microcode = compileMicrocode(hlslProfile);
+
+		if (microcode != nullptr)
+		{
+			mMicrocode.resize(microcode->GetBufferSize());
+			memcpy(&mMicrocode[0], microcode->GetBufferPointer(), microcode->GetBufferSize());
+
+			populateParametersAndConstants(microcode);
+			loadFromMicrocode(rs->getPrimaryDevice(), microcode);
+
+			SAFE_RELEASE(microcode);
+		}
 
-		return rs->getCapabilities()->isShaderProfileSupported(hlslProfile);
+		mProgramId = GlobalProgramId++;
+
+		GpuProgram::initialize_internal();
 	}
 
-	D3D11GpuVertexProgram::D3D11GpuVertexProgram(GpuProgramProfile profile)
-		: D3D11GpuProgram(GPT_VERTEX_PROGRAM, profile)
+	void D3D11GpuProgram::destroy_internal()
+	{
+		mMicrocode.clear();
+
+		mInputDeclaration = nullptr;
+
+		GpuProgram::destroy_internal();
+	}
+
+	ID3DBlob* D3D11GpuProgram::compileMicrocode(const String& profile)
+	{
+		// TODO - Preprocessor defines aren't supported
+
+		UINT compileFlags = 0;
+#if defined(CM_DEBUG_MODE)
+		compileFlags |= D3DCOMPILE_DEBUG;
+		compileFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
+#endif
+
+		if (mColumnMajorMatrices)
+			compileFlags |= D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR;
+		else
+			compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
+
+		if (mEnableBackwardsCompatibility)
+			compileFlags |= D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY;
+
+		ID3DBlob* microCode = nullptr;
+		ID3DBlob* errors = nullptr;
+
+		HRESULT hr = D3DCompile(
+			mSource.c_str(),	// [in] Pointer to the shader in memory. 
+			mSource.size(),		// [in] Size of the shader in memory.  
+			nullptr,			// [in] The name of the file that contains the shader code. 
+			nullptr,			// [in] Optional. Pointer to a NULL-terminated array of macro definitions. See D3D_SHADER_MACRO. If not used, set this to NULL. 
+			nullptr,			// [in] Optional. Pointer to an ID3DInclude Interface interface for handling include files. Setting this to NULL will cause a compile error if a shader contains a #include. 
+			mEntryPoint.c_str(),// [in] Name of the shader-entrypoint function where shader execution begins. 
+			profile.c_str(),// [in] A string that specifies the shader model; can be any profile in shader model 4 or higher. 
+			compileFlags,		// [in] Effect compile flags - no D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY at the first try...
+			0,					// [in] Effect compile flags
+			&microCode,			// [out] A pointer to an ID3DBlob Interface which contains the compiled shader, as well as any embedded debug and symbol-table information. 
+			&errors				// [out] A pointer to an ID3DBlob Interface which contains a listing of errors and warnings that occurred during compilation. These errors and warnings are identical to the the debug output from a debugger.
+			);
+
+		if (FAILED(hr))
+		{
+			mIsCompiled = false;
+			mCompileError = "Cannot compile D3D11 high-level shader. Errors:\n" +
+				String(static_cast<const char*>(errors->GetBufferPointer()));
+
+			SAFE_RELEASE(microCode);
+			SAFE_RELEASE(errors);
+			return nullptr;
+		}
+		else
+		{
+			mIsCompiled = true;
+			mCompileError = "";
+
+			SAFE_RELEASE(errors);
+			return microCode;
+		}
+	}
+
+	void D3D11GpuProgram::populateParametersAndConstants(ID3DBlob* microcode)
+	{
+		assert(microcode != nullptr);
+
+		D3D11HLSLParamParser parser;
+
+		if (mType == GPT_VERTEX_PROGRAM)
+			mInputDeclaration = HardwareBufferManager::instance().createVertexDeclaration();
+
+		parser.parse(microcode, mParametersDesc, mInputDeclaration);
+	}
+
+	GpuParamsPtr D3D11GpuProgram::createParameters()
+	{
+		GpuParamsPtr params = cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc), mColumnMajorMatrices);
+		return params;
+	}
+
+	const String& D3D11GpuProgram::getLanguage() const
+	{
+		static String name = "hlsl";
+
+		return name;
+	}
+
+	/************************************************************************/
+	/* 								SERIALIZATION                      		*/
+	/************************************************************************/
+	RTTITypeBase* D3D11GpuProgram::getRTTIStatic()
+	{
+		return D3D11GpuProgramRTTI::instance();
+	}
+
+	RTTITypeBase* D3D11GpuProgram::getRTTI() const
+	{
+		return D3D11GpuProgram::getRTTIStatic();
+	}
+
+	D3D11GpuVertexProgram::D3D11GpuVertexProgram(const String& source, const String& entryPoint,
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D11GpuProgram(source, entryPoint, GPT_VERTEX_PROGRAM, profile, includes, isAdjacencyInfoRequired)
 		, mVertexShader(nullptr)
 	{ }
 
@@ -39,26 +170,16 @@ namespace BansheeEngine
 
 	void D3D11GpuVertexProgram::loadFromMicrocode(D3D11Device& device, ID3D10Blob*  microcode)
 	{
-		if (isSupported())
-		{
-			// Create the shader
-			HRESULT hr = device.getD3D11Device()->CreateVertexShader( 
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				microcode->GetBufferSize(),
-				device.getClassLinkage(),
-				&mVertexShader);
-
-			if (FAILED(hr) || device.hasError())
-			{
-				String errorDescription = device.getErrorDescription();
-				CM_EXCEPT(RenderingAPIException, 
-					"Cannot create D3D11 vertex shader from microcode\nError Description:" + errorDescription);
-
-			}
-		}
-		else
+		HRESULT hr = device.getD3D11Device()->CreateVertexShader( 
+			static_cast<DWORD*>(microcode->GetBufferPointer()), microcode->GetBufferSize(),
+			device.getClassLinkage(), &mVertexShader);
+
+		if (FAILED(hr) || device.hasError())
 		{
-			LOGWRN("Unsupported D3D11 vertex shader was not loaded.");
+			String errorDescription = device.getErrorDescription();
+			CM_EXCEPT(RenderingAPIException, 
+				"Cannot create D3D11 vertex shader from microcode\nError Description:" + errorDescription);
+
 		}
 	}
 
@@ -69,13 +190,14 @@ namespace BansheeEngine
 		D3D11GpuProgram::destroy_internal();
 	}
 
-	ID3D11VertexShader * D3D11GpuVertexProgram::getVertexShader( void ) const
+	ID3D11VertexShader * D3D11GpuVertexProgram::getVertexShader() const
 	{
 		return mVertexShader;
 	}
 
-	D3D11GpuFragmentProgram::D3D11GpuFragmentProgram(GpuProgramProfile profile)
-		: D3D11GpuProgram(GPT_FRAGMENT_PROGRAM, profile)
+	D3D11GpuFragmentProgram::D3D11GpuFragmentProgram(const String& source, const String& entryPoint,
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D11GpuProgram(source, entryPoint, GPT_FRAGMENT_PROGRAM, profile, includes, isAdjacencyInfoRequired)
 		, mPixelShader(nullptr)
 	{ }
 
@@ -84,25 +206,15 @@ namespace BansheeEngine
 
 	void D3D11GpuFragmentProgram::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
-		if (isSupported())
-		{
-			// Create the shader
-			HRESULT hr = device.getD3D11Device()->CreatePixelShader(
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				microcode->GetBufferSize(),
-				device.getClassLinkage(),
-				&mPixelShader);
-
-			if (FAILED(hr) || device.hasError())
-			{
-				String errorDescription = device.getErrorDescription();
-				CM_EXCEPT(RenderingAPIException, 
-					"Cannot create D3D11 pixel shader from microcode.\nError Description:" + errorDescription);
-			}
-		}
-		else
+		HRESULT hr = device.getD3D11Device()->CreatePixelShader(
+			static_cast<DWORD*>(microcode->GetBufferPointer()), microcode->GetBufferSize(),
+			device.getClassLinkage(), &mPixelShader);
+
+		if (FAILED(hr) || device.hasError())
 		{
-			LOGWRN("Unsupported D3D11 pixel shader was not loaded.");
+			String errorDescription = device.getErrorDescription();
+			CM_EXCEPT(RenderingAPIException, 
+				"Cannot create D3D11 pixel shader from microcode.\nError Description:" + errorDescription);
 		}
 	}
 
@@ -113,13 +225,14 @@ namespace BansheeEngine
 		D3D11GpuProgram::destroy_internal();
 	}
 
-	ID3D11PixelShader * D3D11GpuFragmentProgram::getPixelShader( void ) const
+	ID3D11PixelShader * D3D11GpuFragmentProgram::getPixelShader() const
 	{
 		return mPixelShader;
 	}
 
-	D3D11GpuGeometryProgram::D3D11GpuGeometryProgram(GpuProgramProfile profile)
-		: D3D11GpuProgram(GPT_GEOMETRY_PROGRAM, profile)
+	D3D11GpuGeometryProgram::D3D11GpuGeometryProgram(const String& source, const String& entryPoint,
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D11GpuProgram(source, entryPoint, GPT_GEOMETRY_PROGRAM, profile, includes, isAdjacencyInfoRequired)
 		, mGeometryShader(nullptr)
 	{ }
 
@@ -128,25 +241,15 @@ namespace BansheeEngine
 
 	void D3D11GpuGeometryProgram::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
-		if (isSupported())
-		{
-			// Create the shader
-			HRESULT hr = device.getD3D11Device()->CreateGeometryShader(
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				microcode->GetBufferSize(),
-				device.getClassLinkage(),
-				&mGeometryShader);
-
-			if (FAILED(hr) || device.hasError())
-			{
-				String errorDescription = device.getErrorDescription();
-				CM_EXCEPT(RenderingAPIException, 
-					"Cannot create D3D11 geometry shader from microcode.\nError Description:" + errorDescription);
-			}
-		}
-		else
+		HRESULT hr = device.getD3D11Device()->CreateGeometryShader(
+			static_cast<DWORD*>(microcode->GetBufferPointer()), microcode->GetBufferSize(),
+			device.getClassLinkage(), &mGeometryShader);
+
+		if (FAILED(hr) || device.hasError())
 		{
-			LOGWRN("Unsupported D3D11 geometry shader was not loaded.");
+			String errorDescription = device.getErrorDescription();
+			CM_EXCEPT(RenderingAPIException, 
+				"Cannot create D3D11 geometry shader from microcode.\nError Description:" + errorDescription);
 		}
 	}
 
@@ -157,13 +260,14 @@ namespace BansheeEngine
 		D3D11GpuProgram::destroy_internal();
 	}
 
-	ID3D11GeometryShader * D3D11GpuGeometryProgram::getGeometryShader(void) const
+	ID3D11GeometryShader * D3D11GpuGeometryProgram::getGeometryShader() const
 	{
 		return mGeometryShader;
 	}
 
-	D3D11GpuDomainProgram::D3D11GpuDomainProgram(GpuProgramProfile profile)
-		: D3D11GpuProgram(GPT_DOMAIN_PROGRAM, profile)
+	D3D11GpuDomainProgram::D3D11GpuDomainProgram(const String& source, const String& entryPoint,
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D11GpuProgram(source, entryPoint, GPT_DOMAIN_PROGRAM, profile, includes, isAdjacencyInfoRequired)
 		, mDomainShader(nullptr)
 	{ }
 
@@ -172,25 +276,15 @@ namespace BansheeEngine
 
 	void D3D11GpuDomainProgram::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
-		if (isSupported())
-		{
-			// Create the shader
-			HRESULT hr = device.getD3D11Device()->CreateDomainShader(
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				microcode->GetBufferSize(),
-				device.getClassLinkage(),
-				&mDomainShader);
-
-			if (FAILED(hr) || device.hasError())
-			{
-				String errorDescription = device.getErrorDescription();
-				CM_EXCEPT(RenderingAPIException, 
-					"Cannot create D3D11 domain shader from microcode.\nError Description:" + errorDescription);
-			}
-		}
-		else
+		HRESULT hr = device.getD3D11Device()->CreateDomainShader(
+			static_cast<DWORD*>(microcode->GetBufferPointer()), microcode->GetBufferSize(),
+			device.getClassLinkage(), &mDomainShader);
+
+		if (FAILED(hr) || device.hasError())
 		{
-			LOGWRN("Unsupported D3D11 domain shader was not loaded.");
+			String errorDescription = device.getErrorDescription();
+			CM_EXCEPT(RenderingAPIException, 
+				"Cannot create D3D11 domain shader from microcode.\nError Description:" + errorDescription);
 		}
 	}
 
@@ -206,8 +300,9 @@ namespace BansheeEngine
 		return mDomainShader;
 	}
 
-	D3D11GpuHullProgram::D3D11GpuHullProgram(GpuProgramProfile profile)
-		: D3D11GpuProgram(GPT_HULL_PROGRAM, profile)
+	D3D11GpuHullProgram::D3D11GpuHullProgram(const String& source, const String& entryPoint,
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D11GpuProgram(source, entryPoint, GPT_HULL_PROGRAM, profile, includes, isAdjacencyInfoRequired)
 		, mHullShader(nullptr)
 	{ }
 
@@ -216,25 +311,16 @@ namespace BansheeEngine
 
 	void D3D11GpuHullProgram::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
-		if (isSupported())
-		{
-			// Create the shader
-			HRESULT hr = device.getD3D11Device()->CreateHullShader(
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				microcode->GetBufferSize(),
-				device.getClassLinkage(),
-				&mHullShader);
-
-			if (FAILED(hr) || device.hasError())
-			{
-				String errorDescription = device.getErrorDescription();
-				CM_EXCEPT(RenderingAPIException, 
-					"Cannot create D3D11 hull shader from microcode.\nError Description:" + errorDescription);
-			}
-		}
-		else
+		// Create the shader
+		HRESULT hr = device.getD3D11Device()->CreateHullShader(
+			static_cast<DWORD*>(microcode->GetBufferPointer()), microcode->GetBufferSize(),
+			device.getClassLinkage(), &mHullShader);
+
+		if (FAILED(hr) || device.hasError())
 		{
-			LOGWRN("Unsupported D3D11 hull shader was not loaded.");
+			String errorDescription = device.getErrorDescription();
+			CM_EXCEPT(RenderingAPIException, 
+				"Cannot create D3D11 hull shader from microcode.\nError Description:" + errorDescription);
 		}
 	}
 
@@ -245,13 +331,14 @@ namespace BansheeEngine
 		D3D11GpuProgram::destroy_internal();
 	}
 
-	ID3D11HullShader* D3D11GpuHullProgram::getHullShader(void) const
+	ID3D11HullShader* D3D11GpuHullProgram::getHullShader() const
 	{
 		return mHullShader;
 	}
 
-	D3D11GpuComputeProgram::D3D11GpuComputeProgram(GpuProgramProfile profile)
-		: D3D11GpuProgram(GPT_COMPUTE_PROGRAM, profile)
+	D3D11GpuComputeProgram::D3D11GpuComputeProgram(const String& source, const String& entryPoint,
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D11GpuProgram(source, entryPoint, GPT_COMPUTE_PROGRAM, profile, includes, isAdjacencyInfoRequired)
 		, mComputeShader(nullptr)
 	{ }
 
@@ -260,25 +347,15 @@ namespace BansheeEngine
 
 	void D3D11GpuComputeProgram::loadFromMicrocode(D3D11Device& device, ID3D10Blob* microcode)
 	{
-		if (isSupported())
-		{
-			// Create the shader
-			HRESULT hr = device.getD3D11Device()->CreateComputeShader(
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				microcode->GetBufferSize(),
-				device.getClassLinkage(),
-				&mComputeShader);
-
-			if (FAILED(hr) || device.hasError())
-			{
-				String errorDescription = device.getErrorDescription();
-				CM_EXCEPT(RenderingAPIException, 
-					"Cannot create D3D11 compute shader from microcode.\nError Description:" + errorDescription);
-			}
-		}
-		else
+		HRESULT hr = device.getD3D11Device()->CreateComputeShader(
+			static_cast<DWORD*>(microcode->GetBufferPointer()), microcode->GetBufferSize(),
+			device.getClassLinkage(), &mComputeShader);
+
+		if (FAILED(hr) || device.hasError())
 		{
-			LOGWRN("Unsupported D3D11 compute shader was not loaded.");
+			String errorDescription = device.getErrorDescription();
+			CM_EXCEPT(RenderingAPIException,
+				"Cannot create D3D11 compute shader from microcode.\nError Description:" + errorDescription);
 		}
 	}
 
@@ -289,7 +366,7 @@ namespace BansheeEngine
 		D3D11GpuProgram::destroy_internal();
 	}
 
-	ID3D11ComputeShader* D3D11GpuComputeProgram::getComputeShader(void) const
+	ID3D11ComputeShader* D3D11GpuComputeProgram::getComputeShader() const
 	{
 		return mComputeShader;
 	}

+ 0 - 32
CamelotD3D11RenderSystem/Source/CmD3D11GpuProgramManager.cpp

@@ -1,32 +0,0 @@
-#include "CmD3D11GpuProgramManager.h"
-#include "CmD3D11GpuProgram.h"
-
-namespace BansheeEngine
-{
-	D3D11GpuProgramManager::D3D11GpuProgramManager(D3D11Device& device)
-		:mDevice(device)
-	{ }
-
-	D3D11GpuProgramManager::~D3D11GpuProgramManager()
-	{ }
-
-	GpuProgramPtr D3D11GpuProgramManager::create(const String& source, const String& entryPoint, 
-		GpuProgramType gptype, GpuProgramProfile profile)
-	{
-		switch(gptype)
-		{
-		case GPT_VERTEX_PROGRAM:
-			return cm_core_ptr<D3D11GpuVertexProgram, PoolAlloc>(new (cm_alloc<D3D11GpuVertexProgram, PoolAlloc>()) D3D11GpuVertexProgram(profile));
-		case GPT_FRAGMENT_PROGRAM:
-			return cm_core_ptr<D3D11GpuFragmentProgram, PoolAlloc>(new (cm_alloc<D3D11GpuFragmentProgram, PoolAlloc>()) D3D11GpuFragmentProgram(profile));
-		case GPT_HULL_PROGRAM:
-			return cm_core_ptr<D3D11GpuHullProgram, PoolAlloc>(new (cm_alloc<D3D11GpuHullProgram, PoolAlloc>()) D3D11GpuHullProgram(profile));
-		case GPT_DOMAIN_PROGRAM:
-			return cm_core_ptr<D3D11GpuDomainProgram, PoolAlloc>(new (cm_alloc<D3D11GpuDomainProgram, PoolAlloc>()) D3D11GpuDomainProgram(profile));
-		case GPT_GEOMETRY_PROGRAM:
-			return cm_core_ptr<D3D11GpuGeometryProgram, PoolAlloc>(new (cm_alloc<D3D11GpuGeometryProgram, PoolAlloc>()) D3D11GpuGeometryProgram(profile));
-		}
-		
-		return nullptr;
-	}
-}

+ 0 - 192
CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgram.cpp

@@ -1,192 +0,0 @@
-#include "CmD3D11HLSLProgram.h"
-#include "CmD3D11HLSLProgramRTTI.h"
-#include "CmRenderSystem.h"
-#include "CmGpuProgramManager.h"
-#include "CmD3D11GpuProgram.h"
-#include "CmHardwareBufferManager.h"
-#include "CmD3D11RenderSystem.h"
-#include "CmD3D11HLSLParamParser.h"
-#include "CmD3D11Mappings.h"
-#include "CmGpuParams.h"
-#include "CmException.h"
-#include "CmDebug.h"
-
-namespace BansheeEngine
-{
-	UINT32 D3D11HLSLProgram::globalProgramId = 0;
-
-	D3D11HLSLProgram::D3D11HLSLProgram(const String& source, const String& entryPoint, 
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
-		: HighLevelGpuProgram(source, entryPoint, gptype, profile, includes, isAdjacencyInfoRequired),
-		mColumnMajorMatrices(true), mEnableBackwardsCompatibility(false), mProgramId(0)
-	{
-	}
-
-	D3D11HLSLProgram::~D3D11HLSLProgram()
-	{
-
-	}
-
-    void D3D11HLSLProgram::initialize_internal()
-	{
-		String hlslProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
-
-		ID3DBlob* microcode = compileMicrocode(hlslProfile);
-
-		mMicrocode.resize(microcode->GetBufferSize());
-		memcpy(&mMicrocode[0], microcode->GetBufferPointer(), microcode->GetBufferSize());
-
-		populateParametersAndConstants(microcode);
-
-		mAssemblerProgram = GpuProgramManager::instance().createProgram("", "", mType, mProfile); // We load it from microcode, so none of this matters
-		D3D11RenderSystem* rs = static_cast<D3D11RenderSystem*>(RenderSystem::instancePtr());
-
-		switch(mType)
-		{
-		case GPT_VERTEX_PROGRAM:
-			{
-				D3D11GpuVertexProgramPtr vertProgram = std::static_pointer_cast<D3D11GpuVertexProgram>(mAssemblerProgram);
-				vertProgram->loadFromMicrocode(rs->getPrimaryDevice(), microcode);
-			}
-			break;
-		case GPT_FRAGMENT_PROGRAM:
-			{
-				D3D11GpuFragmentProgramPtr fragProgram = std::static_pointer_cast<D3D11GpuFragmentProgram>(mAssemblerProgram);
-				fragProgram->loadFromMicrocode(rs->getPrimaryDevice(), microcode);
-			}
-			break;
-		case GPT_GEOMETRY_PROGRAM:
-			{
-				D3D11GpuGeometryProgramPtr geomProgram = std::static_pointer_cast<D3D11GpuGeometryProgram>(mAssemblerProgram);
-				geomProgram->loadFromMicrocode(rs->getPrimaryDevice(), microcode);
-			}
-			break;
-		case GPT_HULL_PROGRAM:
-			{
-				D3D11GpuHullProgramPtr hullProgram = std::static_pointer_cast<D3D11GpuHullProgram>(mAssemblerProgram);
-				hullProgram->loadFromMicrocode(rs->getPrimaryDevice(), microcode);
-			}
-			break;
-		case GPT_DOMAIN_PROGRAM:
-			{
-				D3D11GpuDomainProgramPtr domainProgram = std::static_pointer_cast<D3D11GpuDomainProgram>(mAssemblerProgram);
-				domainProgram->loadFromMicrocode(rs->getPrimaryDevice(), microcode);
-			}
-			break;
-		}
-
-		mProgramId = globalProgramId++;
-
-		SAFE_RELEASE(microcode);
-
-		HighLevelGpuProgram::initialize_internal();
-	}
-
-    void D3D11HLSLProgram::destroy_internal()
-	{
-		mAssemblerProgram = nullptr;
-		mMicrocode.clear();
-
-		mInputDeclaration = nullptr;
-
-		HighLevelGpuProgram::destroy_internal();
-	}
-
-	const String& D3D11HLSLProgram::getLanguage() const
-	{
-		static String name = "hlsl";
-
-		return name;
-	}
-
-	bool D3D11HLSLProgram::isSupported() const
-	{
-		RenderSystem* rs = RenderSystem::instancePtr();
-
-		String hlslProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
-
-		return rs->getCapabilities()->isShaderProfileSupported(hlslProfile) && 
-			rs->getCapabilities()->isShaderProfileSupported(getLanguage()) && HighLevelGpuProgram::isSupported();
-	}
-
-	ID3DBlob* D3D11HLSLProgram::compileMicrocode(const String& profile)
-	{
-		// TODO - Preprocessor defines aren't supported
-
-		UINT compileFlags = 0;
-#if defined(CM_DEBUG_MODE)
-		compileFlags |= D3DCOMPILE_DEBUG;
-		compileFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
-#endif
-
-		if (mColumnMajorMatrices)
-			compileFlags |= D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR;
-		else
-			compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
-
-		if (mEnableBackwardsCompatibility)
-			compileFlags |= D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY;
-
-		ID3DBlob* microCode = nullptr;
-		ID3DBlob* errors = nullptr;
-
-		HRESULT hr = D3DCompile(
-			mSource.c_str(),	// [in] Pointer to the shader in memory. 
-			mSource.size(),		// [in] Size of the shader in memory.  
-			nullptr,			// [in] The name of the file that contains the shader code. 
-			nullptr,			// [in] Optional. Pointer to a NULL-terminated array of macro definitions. See D3D_SHADER_MACRO. If not used, set this to NULL. 
-			nullptr,			// [in] Optional. Pointer to an ID3DInclude Interface interface for handling include files. Setting this to NULL will cause a compile error if a shader contains a #include. 
-			mEntryPoint.c_str(),// [in] Name of the shader-entrypoint function where shader execution begins. 
-			profile.c_str(),// [in] A string that specifies the shader model; can be any profile in shader model 4 or higher. 
-			compileFlags,		// [in] Effect compile flags - no D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY at the first try...
-			0,					// [in] Effect compile flags
-			&microCode,			// [out] A pointer to an ID3DBlob Interface which contains the compiled shader, as well as any embedded debug and symbol-table information. 
-			&errors				// [out] A pointer to an ID3DBlob Interface which contains a listing of errors and warnings that occurred during compilation. These errors and warnings are identical to the the debug output from a debugger.
-			);
-
-		if (FAILED(hr))
-		{
-			String message = "Cannot assemble D3D11 high-level shader. Errors:\n" +
-				String(static_cast<const char*>(errors->GetBufferPointer()));
-
-			SAFE_RELEASE(errors);
-			CM_EXCEPT(RenderingAPIException, message);
-		}
-
-		SAFE_RELEASE(errors);
-
-		return microCode;
-	}
-
-	void D3D11HLSLProgram::populateParametersAndConstants(ID3DBlob* microcode)
-	{
-		assert(microcode != nullptr);
-
-		D3D11HLSLParamParser parser;
-
-		if(mType == GPT_VERTEX_PROGRAM)
-			mInputDeclaration = HardwareBufferManager::instance().createVertexDeclaration();
-
-		parser.parse(microcode, mParametersDesc, mInputDeclaration);
-	}
-
-	GpuParamsPtr D3D11HLSLProgram::createParameters()
-	{
-		GpuParamsPtr params = cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc), mColumnMajorMatrices);
-
-		return params;
-	}
-
-	/************************************************************************/
-	/* 								SERIALIZATION                      		*/
-	/************************************************************************/
-	RTTITypeBase* D3D11HLSLProgram::getRTTIStatic()
-	{
-		return D3D11HLSLProgramRTTI::instance();
-	}
-
-	RTTITypeBase* D3D11HLSLProgram::getRTTI() const
-	{
-		return D3D11HLSLProgram::getRTTIStatic();
-	}
-}

+ 28 - 12
CamelotD3D11RenderSystem/Source/CmD3D11HLSLProgramFactory.cpp

@@ -1,9 +1,9 @@
 #include "CmD3D11HLSLProgramFactory.h"
-#include "CmD3D11HLSLProgram.h"
+#include "CmD3D11GpuProgram.h"
 
 namespace BansheeEngine
 {
-    String D3D11HLSLProgramFactory::sLanguageName = "hlsl";
+    const String D3D11HLSLProgramFactory::LANGUAGE_NAME = "hlsl";
 
     D3D11HLSLProgramFactory::D3D11HLSLProgramFactory()
     {
@@ -15,21 +15,37 @@ namespace BansheeEngine
 
     const String& D3D11HLSLProgramFactory::getLanguage(void) const
     {
-        return sLanguageName;
+        return LANGUAGE_NAME;
     }
 
-	HighLevelGpuProgramPtr D3D11HLSLProgramFactory::create(const String& source, const String& entryPoint, 
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes)
+	GpuProgramPtr D3D11HLSLProgramFactory::create(const String& source, const String& entryPoint, 
+		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requireAdjacencyInfo)
     {
-		D3D11HLSLProgram* prog = new (cm_alloc<D3D11HLSLProgram, PoolAlloc>()) D3D11HLSLProgram(source, entryPoint, gptype, profile, includes);
-
-        return cm_core_ptr<D3D11HLSLProgram, PoolAlloc>(prog);
+		switch (gptype)
+		{
+		case GPT_VERTEX_PROGRAM:
+			return cm_core_ptr<D3D11GpuVertexProgram, PoolAlloc>(new (cm_alloc<D3D11GpuVertexProgram, PoolAlloc>()) 
+				D3D11GpuVertexProgram(source, entryPoint, profile, includes, requireAdjacencyInfo));
+		case GPT_FRAGMENT_PROGRAM:
+			return cm_core_ptr<D3D11GpuFragmentProgram, PoolAlloc>(new (cm_alloc<D3D11GpuFragmentProgram, PoolAlloc>()) 
+				D3D11GpuFragmentProgram(source, entryPoint, profile, includes, requireAdjacencyInfo));
+		case GPT_HULL_PROGRAM:
+			return cm_core_ptr<D3D11GpuHullProgram, PoolAlloc>(new (cm_alloc<D3D11GpuHullProgram, PoolAlloc>()) 
+				D3D11GpuHullProgram(source, entryPoint, profile, includes, requireAdjacencyInfo));
+		case GPT_DOMAIN_PROGRAM:
+			return cm_core_ptr<D3D11GpuDomainProgram, PoolAlloc>(new (cm_alloc<D3D11GpuDomainProgram, PoolAlloc>()) 
+				D3D11GpuDomainProgram(source, entryPoint, profile, includes, requireAdjacencyInfo));
+		case GPT_GEOMETRY_PROGRAM:
+			return cm_core_ptr<D3D11GpuGeometryProgram, PoolAlloc>(new (cm_alloc<D3D11GpuGeometryProgram, PoolAlloc>()) 
+				D3D11GpuGeometryProgram(source, entryPoint, profile, includes, requireAdjacencyInfo));
+		}
+
+		return nullptr;
     }
 
-	HighLevelGpuProgramPtr D3D11HLSLProgramFactory::create()
+	GpuProgramPtr D3D11HLSLProgramFactory::create()
 	{
-		D3D11HLSLProgram* prog = new (cm_alloc<D3D11HLSLProgram, PoolAlloc>()) D3D11HLSLProgram("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
-
-		return cm_core_ptr<D3D11HLSLProgram, PoolAlloc>(prog);
+		return cm_core_ptr<D3D11GpuVertexProgram, PoolAlloc>(new (cm_alloc<D3D11GpuVertexProgram, PoolAlloc>())
+			D3D11GpuVertexProgram("", "", GPP_NONE, nullptr, false));
 	}
 }

+ 3 - 3
CamelotD3D11RenderSystem/Source/CmD3D11InputLayoutManager.cpp

@@ -2,7 +2,7 @@
 #include "CmD3D11Mappings.h"
 #include "CmD3D11RenderSystem.h"
 #include "CmD3D11Device.h"
-#include "CmD3D11HLSLProgram.h"
+#include "CmD3D11GpuProgram.h"
 #include "CmHardwareBufferManager.h"
 #include "CmDebug.h"
 #include "CmUtil.h"
@@ -63,7 +63,7 @@ namespace BansheeEngine
 		}
 	}
 
-	ID3D11InputLayout* D3D11InputLayoutManager::retrieveInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11HLSLProgram& vertexProgram)
+	ID3D11InputLayout* D3D11InputLayoutManager::retrieveInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgram& vertexProgram)
 	{
 		VertexDeclarationKey pair;
 		pair.bufferDeclHash = vertexBufferDecl->getHash();
@@ -88,7 +88,7 @@ namespace BansheeEngine
 		return iterFind->second->inputLayout;
 	}
 
-	void D3D11InputLayoutManager::addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11HLSLProgram& vertexProgram)
+	void D3D11InputLayoutManager::addNewInputLayout(VertexDeclarationPtr vertexShaderDecl, VertexDeclarationPtr vertexBufferDecl, D3D11GpuProgram& vertexProgram)
 	{
 		if(!areCompatible(vertexShaderDecl, vertexBufferDecl))
 			return; // Error was already reported, so just quit here

+ 8 - 14
CamelotD3D11RenderSystem/Source/CmD3D11RenderSystem.cpp

@@ -5,7 +5,6 @@
 #include "CmD3D11TextureManager.h"
 #include "CmD3D11Texture.h"
 #include "CmD3D11HardwareBufferManager.h"
-#include "CmD3D11GpuProgramManager.h"
 #include "CmD3D11RenderWindowManager.h"
 #include "CmD3D11HLSLProgramFactory.h"
 #include "CmD3D11BlendState.h"
@@ -19,7 +18,6 @@
 #include "CmD3D11RenderStateManager.h"
 #include "CmD3D11GpuParamBlockBuffer.h"
 #include "CmD3D11InputLayoutManager.h"
-#include "CmD3D11HLSLProgram.h"
 #include "CmD3D11RenderUtility.h"
 #include "CmBindableGpuParams.h"
 #include "CmCoreThread.h"
@@ -109,9 +107,6 @@ namespace BansheeEngine
 		// Also create hardware buffer manager		
 		HardwareBufferManager::startUp(cm_new<D3D11HardwareBufferManager>(std::ref(*mDevice)));
 
-		// Create the GPU program manager		
-		GpuProgramManager::startUp(cm_new<D3D11GpuProgramManager>(std::ref(*mDevice)));
-
 		// Create render window manager
 		RenderWindowManager::startUp(cm_new<D3D11RenderWindowManager>(this));
 
@@ -124,7 +119,7 @@ namespace BansheeEngine
 		mCurrentCapabilities = createRenderSystemCapabilities();
 
 		mCurrentCapabilities->addShaderProfile("hlsl");
-		HighLevelGpuProgramManager::instance().addFactory(mHLSLFactory);
+		GpuProgramManager::instance().addFactory(mHLSLFactory);
 
 		mIAManager = cm_new<D3D11InputLayoutManager>();
 
@@ -163,7 +158,6 @@ namespace BansheeEngine
 
 		RenderStateManager::shutDown();
 		RenderWindowManager::shutDown();
-		GpuProgramManager::shutDown();
 		HardwareBufferManager::shutDown();
 		TextureManager::shutDown();
 
@@ -400,38 +394,38 @@ namespace BansheeEngine
 		{
 		case GPT_VERTEX_PROGRAM:
 			{
-				D3D11GpuVertexProgram* d3d11GpuProgram = static_cast<D3D11GpuVertexProgram*>(prg->getBindingDelegate().get());
+				D3D11GpuVertexProgram* d3d11GpuProgram = static_cast<D3D11GpuVertexProgram*>(prg.get());
 				mDevice->getImmediateContext()->VSSetShader(d3d11GpuProgram->getVertexShader(), nullptr, 0);
-				mActiveVertexShader = std::static_pointer_cast<D3D11HLSLProgram>(prg.getInternalPtr());
+				mActiveVertexShader = std::static_pointer_cast<D3D11GpuProgram>(prg.getInternalPtr());
 				break;
 			}
 		case GPT_FRAGMENT_PROGRAM:
 			{
-				D3D11GpuFragmentProgram* d3d11GpuProgram = static_cast<D3D11GpuFragmentProgram*>(prg->getBindingDelegate().get());
+				D3D11GpuFragmentProgram* d3d11GpuProgram = static_cast<D3D11GpuFragmentProgram*>(prg.get());
 				mDevice->getImmediateContext()->PSSetShader(d3d11GpuProgram->getPixelShader(), nullptr, 0);
 				break;
 			}
 		case GPT_GEOMETRY_PROGRAM:
 			{
-				D3D11GpuGeometryProgram* d3d11GpuProgram = static_cast<D3D11GpuGeometryProgram*>(prg->getBindingDelegate().get());
+				D3D11GpuGeometryProgram* d3d11GpuProgram = static_cast<D3D11GpuGeometryProgram*>(prg.get());
 				mDevice->getImmediateContext()->GSSetShader(d3d11GpuProgram->getGeometryShader(), nullptr, 0);
 				break;
 			}
 		case GPT_DOMAIN_PROGRAM:
 			{
-				D3D11GpuDomainProgram* d3d11GpuProgram = static_cast<D3D11GpuDomainProgram*>(prg->getBindingDelegate().get());
+				D3D11GpuDomainProgram* d3d11GpuProgram = static_cast<D3D11GpuDomainProgram*>(prg.get());
 				mDevice->getImmediateContext()->DSSetShader(d3d11GpuProgram->getDomainShader(), nullptr, 0);
 				break;
 			}
 		case GPT_HULL_PROGRAM:
 			{
-				D3D11GpuHullProgram* d3d11GpuProgram = static_cast<D3D11GpuHullProgram*>(prg->getBindingDelegate().get());
+				D3D11GpuHullProgram* d3d11GpuProgram = static_cast<D3D11GpuHullProgram*>(prg.get());
 				mDevice->getImmediateContext()->HSSetShader(d3d11GpuProgram->getHullShader(), nullptr, 0);
 				break;
 			}
 		case GPT_COMPUTE_PROGRAM:
 			{
-				D3D11GpuComputeProgram* d3d11GpuProgram = static_cast<D3D11GpuComputeProgram*>(prg->getBindingDelegate().get());
+				D3D11GpuComputeProgram* d3d11GpuProgram = static_cast<D3D11GpuComputeProgram*>(prg.get());
 				mDevice->getImmediateContext()->CSSetShader(d3d11GpuProgram->getComputeShader(), nullptr, 0);
 				break;
 			}

+ 1 - 5
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj

@@ -240,7 +240,6 @@
     <ClInclude Include="Include\CmD3D9EventQuery.h" />
     <ClInclude Include="Include\CmD3D9GpuBuffer.h" />
     <ClInclude Include="Include\CmD3D9GpuProgram.h" />
-    <ClInclude Include="Include\CmD3D9GpuProgramManager.h" />
     <ClInclude Include="Include\CmD3D9HardwareBufferManager.h" />
     <ClInclude Include="Include\CmD3D9HLSLParamParser.h" />
     <ClInclude Include="Include\CmD3D9IndexBuffer.h" />
@@ -249,9 +248,8 @@
     <ClInclude Include="Include\CmD3D9QueryManager.h" />
     <ClInclude Include="Include\CmD3D9TimerQuery.h" />
     <ClInclude Include="Include\CmD3D9VertexBuffer.h" />
-    <ClInclude Include="Include\CmD3D9HLSLProgram.h" />
     <ClInclude Include="Include\CmD3D9HLSLProgramFactory.h" />
-    <ClInclude Include="Include\CmD3D9HLSLProgramRTTI.h" />
+    <ClInclude Include="Include\CmD3D9GpuProgramRTTI.h" />
     <ClInclude Include="Include\CmD3D9Mappings.h" />
     <ClInclude Include="Include\CmD3D9MultiRenderTexture.h" />
     <ClInclude Include="Include\CmD3D9Prerequisites.h" />
@@ -277,7 +275,6 @@
     <ClCompile Include="Source\CmD3D9EventQuery.cpp" />
     <ClCompile Include="Source\CmD3D9GpuBuffer.cpp" />
     <ClCompile Include="Source\CmD3D9GpuProgram.cpp" />
-    <ClCompile Include="Source\CmD3D9GpuProgramManager.cpp" />
     <ClCompile Include="Source\CmD3D9HardwareBufferManager.cpp" />
     <ClCompile Include="Source\CmD3D9IndexBuffer.cpp" />
     <ClCompile Include="Source\CmD3D9OcclusionQuery.cpp" />
@@ -285,7 +282,6 @@
     <ClCompile Include="Source\CmD3D9QueryManager.cpp" />
     <ClCompile Include="Source\CmD3D9TimerQuery.cpp" />
     <ClCompile Include="Source\CmD3D9VertexBuffer.cpp" />
-    <ClCompile Include="Source\CmD3D9HLSLProgram.cpp" />
     <ClCompile Include="Source\CmD3D9HLSLProgramFactory.cpp" />
     <ClCompile Include="Source\CmD3D9Mappings.cpp" />
     <ClCompile Include="Source\CmD3D9MultiRenderTexture.cpp" />

+ 3 - 15
CamelotD3D9Renderer/CamelotD3D9Renderer.vcxproj.filters

@@ -33,15 +33,9 @@
     <ClInclude Include="Include\CmD3D9GpuProgram.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D9GpuProgramManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D9HardwareBufferManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D9HLSLProgram.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D9HLSLProgramFactory.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -81,9 +75,6 @@
     <ClInclude Include="Include\CmD3D9VideoModeList.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmD3D9HLSLProgramRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmD3D9RenderWindowManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -120,6 +111,9 @@
     <ClInclude Include="Include\CmD3D9TimerQuery.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmD3D9GpuProgramRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmD3D9Device.cpp">
@@ -137,15 +131,9 @@
     <ClCompile Include="Source\CmD3D9GpuProgram.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmD3D9GpuProgramManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmD3D9HardwareBufferManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmD3D9HLSLProgram.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmD3D9HLSLProgramFactory.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>

+ 54 - 66
CamelotD3D9Renderer/Include/CmD3D9GpuProgram.h

@@ -1,39 +1,20 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __D3D9GpuProgram_H_
-#define __D3D9GpuProgram_H_
-
-// Precompiler options
+#pragma once
+
 #include "CmD3D9Prerequisites.h"
 #include "CmGpuProgram.h"
 #include "CmD3D9Resource.h"
 
-namespace BansheeEngine {
+namespace BansheeEngine 
+{
+	enum OptimizationLevel
+	{
+		OPT_DEFAULT,
+		OPT_NONE,
+		OPT_0,
+		OPT_1,
+		OPT_2,
+		OPT_3
+	};
 
     /** Direct3D implementation of a few things common to low-level vertex & fragment programs. */
     class CM_D3D9_EXPORT D3D9GpuProgram : public GpuProgram, public D3D9Resource
@@ -41,28 +22,35 @@ namespace BansheeEngine {
     public:
         ~D3D9GpuProgram();
 
+		/** Sets the preprocessor defines use to compile the program. */
+		void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
+		/** Sets the preprocessor defines use to compile the program. */
+		const String& getPreprocessorDefines() const { return mPreprocessorDefines; }
+
         /** Sets whether matrix packing in column-major order. */ 
         void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
         /** Gets whether matrix packed in column-major order. */
-        bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
+        bool getColumnMajorMatrices() const { return mColumnMajorMatrices; }
 
-		/** Tells the program to load from some externally created microcode instead of a file or source. 
+		/** Sets the optimisation level to use.
+		@param opt Optimisation level
 		*/
-		void setExternalMicrocode(const void* pMicrocode, UINT32 size);
-        /** Tells the program to load from some externally created microcode instead of a file or source. 
-        @remarks
-            add ref count to pMicrocode when setting
-        */ 
-        void setExternalMicrocode(ID3DXBuffer* pMicrocode);
-        /** Gets the external microcode buffer, if any. */
-        LPD3DXBUFFER getExternalMicrocode(void);
-
-		bool isSupported() const;
+		void setOptimizationLevel(OptimizationLevel opt) { mOptimisationLevel = opt; }
+
+		/** Gets the optimisation level to use. */
+		OptimizationLevel getOptimizationLevel() const { return mOptimisationLevel; }
+
+		/// Overridden from GpuProgram
+		GpuParamsPtr createParameters();
+		/// Overridden from GpuProgram
+		const String& getLanguage() const;
+
     protected:
-		friend class D3D9GpuProgramManager;
+		friend class D3D9HLSLProgramFactory;
 
 		D3D9GpuProgram(const String& source, const String& entryPoint, 
-			GpuProgramType gptype, GpuProgramProfile profile);
+			GpuProgramType gptype, GpuProgramProfile profile, 
+			const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired = false);
 
 		void createInternalResources(IDirect3DDevice9* d3d9Device);
 
@@ -79,18 +67,19 @@ namespace BansheeEngine {
 		/** Loads this program from microcode, must be overridden by subclasses. */
         virtual void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) = 0;
 
-        /** Creates a new parameters object compatible with this program definition. 
-        @remarks
-            It is recommended that you use this method of creating parameters objects
-            rather than going direct to GpuProgramManager, because this method will
-            populate any implementation-specific extras (like named parameters) where
-            they are appropriate.
-        */
-        virtual GpuParamsPtr createParameters();
 	protected:    
+		OptimizationLevel mOptimisationLevel;
+		String mPreprocessorDefines;
 		bool mColumnMajorMatrices;
-		ID3DXBuffer* mpExternalMicrocode;
-
+		ID3DXBuffer* mMicrocode;
+
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class D3D9GpuProgramRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
     };
 
     /** Direct3D implementation of low-level vertex programs. */
@@ -100,7 +89,7 @@ namespace BansheeEngine {
 		~D3D9GpuVertexProgram();
         
 		/// Gets the vertex shader
-        IDirect3DVertexShader9* getVertexShader(void);
+        IDirect3DVertexShader9* getVertexShader();
 
 		// Called immediately after the Direct3D device has been created.
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
@@ -109,9 +98,10 @@ namespace BansheeEngine {
 		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
 
     protected:
-		friend class D3D9GpuProgramManager;
+		friend class D3D9HLSLProgramFactory;
 
-		D3D9GpuVertexProgram(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile);
+		D3D9GpuVertexProgram(const String& source, const String& entryPoint, GpuProgramProfile profile,
+			const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired = false);
 
 		/**
 		 * @copydoc D3D9GpuProgram::destroy_internal.
@@ -134,7 +124,7 @@ namespace BansheeEngine {
 		~D3D9GpuFragmentProgram();
 
         /// Gets the pixel shader
-        IDirect3DPixelShader9* getPixelShader(void);
+        IDirect3DPixelShader9* getPixelShader();
 
 		// Called immediately after the Direct3D device has been created.
 		virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
@@ -143,9 +133,10 @@ namespace BansheeEngine {
 		virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
 
     protected:
-		friend class D3D9GpuProgramManager;
+		friend class D3D9HLSLProgramFactory;
 
-		D3D9GpuFragmentProgram(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile);
+		D3D9GpuFragmentProgram(const String& source, const String& entryPoint, GpuProgramProfile profile,
+			const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired = false);
 
 		/**
 		 * @copydoc D3D9GpuProgram::destroy_internal.
@@ -162,7 +153,4 @@ namespace BansheeEngine {
     };
 
 	typedef std::shared_ptr<D3D9GpuProgram> D3D9GpuProgramPtr;
-}
-
-
-#endif
+}

+ 0 - 49
CamelotD3D9Renderer/Include/CmD3D9GpuProgramManager.h

@@ -1,49 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __D3D9GpuProgramManager_H__
-#define __D3D9GpuProgramManager_H__
-
-#include "CmD3D9Prerequisites.h"
-#include "CmGpuProgram.h"
-#include "CmGpuProgramManager.h"
-
-namespace BansheeEngine {
-
-    class CM_D3D9_EXPORT D3D9GpuProgramManager : public GpuProgramManager
-    {
-    public:
-        D3D9GpuProgramManager();
-		~D3D9GpuProgramManager();
-
-	protected:
-		GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile);
-    };
-
-}
-
-#endif

+ 0 - 120
CamelotD3D9Renderer/Include/CmD3D9HLSLProgram.h

@@ -1,120 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __D3D9HLSLProgram_H__
-#define __D3D9HLSLProgram_H__
-
-#include "CmD3D9Prerequisites.h"
-#include "CmHighLevelGpuProgram.h"
-
-namespace BansheeEngine {
-    /** Specialisation of HighLevelGpuProgram to provide support for D3D9 
-        High-Level Shader Language (HLSL).
-    */
-    class CM_D3D9_EXPORT D3D9HLSLProgram : public HighLevelGpuProgram
-    {
-	public:
-		LPD3DXBUFFER getMicroCode();
-	public:
-		/// Shader optimisation level
-		enum OptimisationLevel
-		{
-			/// default - no optimisation in debug mode, OPT_1 in release mode
-			OPT_DEFAULT,
-			/// No optimisation
-			OPT_NONE,
-			/// Optimisation level 0
-			OPT_0, 
-			/// Optimisation level 1
-			OPT_1,
-			/// Optimisation level 2
-			OPT_2, 
-			/// Optimisation level 3
-			OPT_3
-		};
-	protected:
-		OptimisationLevel mOptimisationLevel;
-
-    public:
-        ~D3D9HLSLProgram();
-
-        /** Sets the preprocessor defines use to compile the program. */
-        void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
-        /** Sets the preprocessor defines use to compile the program. */
-        const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
-        /** Sets whether matrix packing in column-major order. */ 
-        void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
-        /** Gets whether matrix packed in column-major order. */
-        bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
-		/** Sets the optimisation level to use.
-		@param opt Optimisation level
-		*/
-		void setOptimisationLevel(OptimisationLevel opt) { mOptimisationLevel = opt; }
-
-		/** Gets the optimisation level to use. */
-		OptimisationLevel getOptimisationLevel() const { return mOptimisationLevel; }
-
-        /// Overridden from GpuProgram
-        bool isSupported(void) const;
-        /// Overridden from GpuProgram
-        GpuParamsPtr createParameters();
-        /// Overridden from GpuProgram
-        const String& getLanguage(void) const;
-
-    protected:
-		friend class D3D9HLSLProgramFactory;
-
-		D3D9HLSLProgram(const String& source, const String& entryPoint, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, 
-			bool isAdjacencyInfoRequired = false);
- 
-		/**
-		 * @copydoc HighLevelGpuProgram::initialize_internal().
-		 */
-		void initialize_internal();
-
-		/**
-		 * @copydoc HighLevelGpuProgram::destroy_internal().
-		 */
-        void destroy_internal();
-
-        String mPreprocessorDefines;
-        bool mColumnMajorMatrices;
-
-        LPD3DXBUFFER mpMicroCode;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class D3D9HLSLProgramRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-    };
-}
-
-#endif

+ 14 - 41
CamelotD3D9Renderer/Include/CmD3D9HLSLProgramFactory.h

@@ -1,52 +1,25 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __D3D9HLSLProgramFactory_H__
-#define __D3D9HLSLProgramFactory_H__
+#pragma once
 
 #include "CmD3D9Prerequisites.h"
-#include "CmHighLevelGpuProgramManager.h"
+#include "CmGpuProgramManager.h"
 
 namespace BansheeEngine
 {
     /** Factory class for D3D9 HLSL programs. */
-    class CM_D3D9_EXPORT D3D9HLSLProgramFactory : public HighLevelGpuProgramFactory
+    class CM_D3D9_EXPORT D3D9HLSLProgramFactory : public GpuProgramFactory
     {
-    protected:
-		static String sLanguageName;
     public:
         D3D9HLSLProgramFactory();
         ~D3D9HLSLProgramFactory();
-		/// Get the name of the language this factory creates programs for
-		const String& getLanguage(void) const;
-        HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
-			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
-		HighLevelGpuProgramPtr create();
-    };
-}
 
-#endif
+		const String& getLanguage() const;
+
+        GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency);
+
+		GpuProgramPtr create();
+
+	protected:
+		static String LANGUAGE_NAME;
+    };
+}

+ 0 - 33
CamelotD3D9Renderer/Include/CmD3D9HLSLProgramRTTI.h

@@ -1,33 +0,0 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmHighLevelGpuProgram.h"
-#include "CmD3D9HLSLProgram.h"
-
-namespace BansheeEngine
-{
-	class CM_D3D9_EXPORT D3D9HLSLProgramRTTI : public RTTIType<D3D9HLSLProgram, HighLevelGpuProgram, D3D9HLSLProgramRTTI>
-	{
-	public:
-		D3D9HLSLProgramRTTI()
-		{ }
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "D3D9HLSLProgram";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_D3D9_HLSLProgram;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return HighLevelGpuProgramManager::instance().createEmpty("hlsl");
-		}
-	};
-}

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9Prerequisites.h

@@ -82,7 +82,7 @@ namespace BansheeEngine
 
 	enum TypeID_D3D9
 	{
-		TID_D3D9_HLSLProgram = 10000
+		TID_D3D9_GpuProgram = 10000
 	};
 
     //-------------------------------------------

+ 234 - 172
CamelotD3D9Renderer/Source/CmD3D9GpuProgram.cpp

@@ -1,30 +1,3 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
 #include "CmD3D9GpuProgram.h"
 #include "CmMatrix4.h"
 #include "CmException.h"
@@ -34,107 +7,201 @@ THE SOFTWARE.
 #include "CmGpuParams.h"
 #include "CmAsyncOp.h"
 #include "CmGpuProgramManager.h"
+#include "CmD3D9HLSLParamParser.h"
+#include "CmD3D9GpuProgramRTTI.h"
 
-namespace BansheeEngine {
-    //-----------------------------------------------------------------------------
+namespace BansheeEngine 
+{
     D3D9GpuProgram::D3D9GpuProgram(const String& source, const String& entryPoint, 
-		GpuProgramType gptype, GpuProgramProfile profile) 
-        : GpuProgram(source, entryPoint, gptype, profile, nullptr), mpExternalMicrocode(NULL), mColumnMajorMatrices(false)
-    {
-    }
+		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: GpuProgram(source, entryPoint, gptype, profile, includes, isAdjacencyInfoRequired),
+		mMicrocode(nullptr), mColumnMajorMatrices(false), mOptimisationLevel(OPT_DEFAULT)
+    { }
 
-	//-----------------------------------------------------------------------------
 	D3D9GpuProgram::~D3D9GpuProgram()
-	{
+	{ }
 
-	}
-	//-----------------------------------------------------------------------------
 	void D3D9GpuProgram::initialize_internal()
 	{
-		for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
+		if (!isSupported())
 		{
-			IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
+			mIsCompiled = false;
+			mCompileError = "Specified program is not supported by the current render system.";
 
-			createInternalResources(d3d9Device);
-		}		       
+			return;
+		}
 
-		GpuProgram::initialize_internal();
-	}
-	//----------------------------------------------------------------------------
-	void D3D9GpuProgram::destroy_internal()
-	{
-		SAFE_RELEASE(mpExternalMicrocode);
+		// Populate preprocessor defines
+		String stringBuffer;
 
-		GpuProgram::destroy_internal();
-	}
-	//-----------------------------------------------------------------------------
-	void D3D9GpuProgram::setExternalMicrocode(const void* pMicrocode, UINT32 size)
-	{
-		LPD3DXBUFFER pBuffer=0;
-		HRESULT hr = D3DXCreateBuffer(size, &pBuffer);
-		if(pBuffer)
+		Vector<D3DXMACRO> defines;
+		const D3DXMACRO* pDefines = 0;
+		if (!mPreprocessorDefines.empty())
 		{
-			memcpy(pBuffer->GetBufferPointer(), pMicrocode, size);
-			this->setExternalMicrocode(pBuffer);
-			SAFE_RELEASE(pBuffer);
+			stringBuffer = mPreprocessorDefines;
+
+			// Split preprocessor defines and build up macro array
+			D3DXMACRO macro;
+			String::size_type pos = 0;
+			while (pos != String::npos)
+			{
+				macro.Name = &stringBuffer[pos];
+				macro.Definition = 0;
+
+				String::size_type start_pos = pos;
+
+				// Find delims
+				pos = stringBuffer.find_first_of(";,=", pos);
+
+				if (start_pos == pos)
+				{
+					if (pos == stringBuffer.length())
+					{
+						break;
+					}
+					pos++;
+					continue;
+				}
+
+				if (pos != String::npos)
+				{
+					// Check definition part
+					if (stringBuffer[pos] == '=')
+					{
+						// Setup null character for macro name
+						stringBuffer[pos++] = '\0';
+						macro.Definition = &stringBuffer[pos];
+						pos = stringBuffer.find_first_of(";,", pos);
+					}
+					else
+					{
+						// No definition part, define as "1"
+						macro.Definition = "1";
+					}
+
+					if (pos != String::npos)
+					{
+						// Setup null character for macro name or definition
+						stringBuffer[pos++] = '\0';
+					}
+				}
+				else
+				{
+					macro.Definition = "1";
+				}
+				if (strlen(macro.Name) > 0)
+				{
+					defines.push_back(macro);
+				}
+				else
+				{
+					break;
+				}
+			}
+
+			// Add NULL terminator
+			macro.Name = 0;
+			macro.Definition = 0;
+			defines.push_back(macro);
+
+			pDefines = &defines[0];
 		}
-	}
-	//-----------------------------------------------------------------------------
-	void D3D9GpuProgram::setExternalMicrocode(ID3DXBuffer* pMicrocode)
-	{ 
-		SAFE_RELEASE(mpExternalMicrocode);
-		mpExternalMicrocode = pMicrocode;
-		if(mpExternalMicrocode)
+
+		// Populate compile flags
+		DWORD compileFlags = 0;
+		if (mColumnMajorMatrices)
+			compileFlags |= D3DXSHADER_PACKMATRIX_COLUMNMAJOR;
+		else
+			compileFlags |= D3DXSHADER_PACKMATRIX_ROWMAJOR;
+
+#if CM_DEBUG_MODE
+		compileFlags |= D3DXSHADER_DEBUG;
+#endif
+		switch (mOptimisationLevel)
 		{
-			mpExternalMicrocode->AddRef();	
+		case OPT_DEFAULT:
+			compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL1;
+			break;
+		case OPT_NONE:
+			compileFlags |= D3DXSHADER_SKIPOPTIMIZATION;
+			break;
+		case OPT_0:
+			compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL0;
+			break;
+		case OPT_1:
+			compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL1;
+			break;
+		case OPT_2:
+			compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL2;
+			break;
+		case OPT_3:
+			compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL3;
+			break;
 		}
-	}
-    //-----------------------------------------------------------------------------
-	LPD3DXBUFFER D3D9GpuProgram::getExternalMicrocode(void)
-	{
-		return mpExternalMicrocode;
-	}
-	//-----------------------------------------------------------------------------
-	void D3D9GpuProgram::createInternalResources(IDirect3DDevice9* d3d9Device)
-	{
-		if (mpExternalMicrocode)
+
+		LPD3DXBUFFER errors = 0;
+
+		// include handler
+		LPD3DXCONSTANTTABLE constTable;
+
+		String hlslProfile = D3D9RenderSystem::instance().getCapabilities()->gpuProgProfileToRSSpecificProfile(mProfile);
+
+		// Compile & assemble into microcode
+		HRESULT hr = D3DXCompileShader(
+			mSource.c_str(),
+			static_cast<UINT>(mSource.length()),
+			pDefines,
+			nullptr,
+			mEntryPoint.c_str(),
+			hlslProfile.c_str(),
+			compileFlags,
+			&mMicrocode,
+			&errors,
+			&constTable);
+
+		if (FAILED(hr))
 		{
-			loadFromMicrocode(d3d9Device, mpExternalMicrocode);
+			String message = "Cannot compile D3D9 high-level shader ";
+
+			if (errors)
+			{
+				message += String(" Errors:\n") + static_cast<const char*>(errors->GetBufferPointer());
+				errors->Release();
+			}
+
+			mIsCompiled = false;
+			mCompileError = message;
+
+			SAFE_RELEASE(mMicrocode);
+			mMicrocode = nullptr;
 		}
 		else
 		{
-			// Populate compile flags
-			DWORD compileFlags = 0;
-
-			// Create the shader
-			// Assemble source into microcode
-			LPD3DXBUFFER microcode;
-			LPD3DXBUFFER errors;
-			HRESULT hr = D3DXAssembleShader(
-				mSource.c_str(),
-				static_cast<UINT>(mSource.length()),
-				NULL,               // no #define support
-				NULL,               // no #include support
-				compileFlags,       // standard compile options
-				&microcode,
-				&errors);
-
-			if (FAILED(hr))
+			for (UINT32 i = 0; i < D3D9RenderSystem::getResourceCreationDeviceCount(); ++i)
 			{
-				String message = "Cannot assemble D3D9 shader. Errors:\n";
-				message += static_cast<const char*>(errors->GetBufferPointer());
-
-				errors->Release();
-				CM_EXCEPT(RenderingAPIException, message);
+				IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getResourceCreationDevice(i);
+				createInternalResources(d3d9Device);
 			}
 
-			loadFromMicrocode(d3d9Device, microcode);		
+			D3D9HLSLParamParser paramParser(constTable);
+			mParametersDesc = paramParser.buildParameterDescriptions();
+
+			mIsCompiled = true;
+			mCompileError = "";
 
-			SAFE_RELEASE(microcode);
-			SAFE_RELEASE(errors);
+			SAFE_RELEASE(constTable);
 		}
+
+		GpuProgram::initialize_internal();
+	}
+
+	void D3D9GpuProgram::destroy_internal()
+	{
+		SAFE_RELEASE(mMicrocode);
+
+		GpuProgram::destroy_internal();
 	}
-    //-----------------------------------------------------------------------
+
 	GpuParamsPtr D3D9GpuProgram::createParameters()
 	{
 		GpuParamsPtr params = cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc), mColumnMajorMatrices);
@@ -142,27 +209,42 @@ namespace BansheeEngine {
 		return params;
 	}
 
-	bool D3D9GpuProgram::isSupported() const
+	void D3D9GpuProgram::createInternalResources(IDirect3DDevice9* d3d9Device)
+	{
+		loadFromMicrocode(d3d9Device, mMicrocode);
+	}
+
+	const String& D3D9GpuProgram::getLanguage() const
 	{
-		if (!isRequiredCapabilitiesSupported())
-			return false;
+		static const String language = "hlsl";
 
-		RenderSystem* rs = BansheeEngine::RenderSystem::instancePtr();
-		String hlslProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
+		return language;
+	}
 
-		return rs->getCapabilities()->isShaderProfileSupported(hlslProfile);
+	/************************************************************************/
+	/* 								SERIALIZATION                      		*/
+	/************************************************************************/
+	RTTITypeBase* D3D9GpuProgram::getRTTIStatic()
+	{
+		return D3D9GpuProgramRTTI::instance();
 	}
-	//-----------------------------------------------------------------------------
-	D3D9GpuVertexProgram::D3D9GpuVertexProgram(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile) 
-        : D3D9GpuProgram(source, entryPoint, gptype, profile)       
+
+	RTTITypeBase* D3D9GpuProgram::getRTTI() const
+	{
+		return D3D9GpuProgram::getRTTIStatic();
+	}
+
+	D3D9GpuVertexProgram::D3D9GpuVertexProgram(const String& source, const String& entryPoint, 
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D9GpuProgram(source, entryPoint, GPT_VERTEX_PROGRAM, profile, includes, isAdjacencyInfoRequired)
     {
-        mType = GPT_VERTEX_PROGRAM;		
+
     }
-	//-----------------------------------------------------------------------------
+
 	D3D9GpuVertexProgram::~D3D9GpuVertexProgram()
 	{	
 	}
-	//-----------------------------------------------------------------------------
+
 	void D3D9GpuVertexProgram::destroy_internal(void)
 	{
 		DeviceToVertexShaderIterator it = mMapDeviceToVertexShader.begin();
@@ -176,7 +258,7 @@ namespace BansheeEngine {
 
 		D3D9GpuProgram::destroy_internal();
 	}
-	//-----------------------------------------------------------------------------
+
     void D3D9GpuVertexProgram::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)
     {		 
 		DeviceToVertexShaderIterator it = mMapDeviceToVertexShader.find(d3d9Device);
@@ -184,36 +266,27 @@ namespace BansheeEngine {
 		if (it != mMapDeviceToVertexShader.end())
 			SAFE_RELEASE(it->second);
 
-		if (isSupported())
-		{
-			// Create the shader
-			IDirect3DVertexShader9* pVertexShader;
-			HRESULT hr;
+		// Create the shader
+		IDirect3DVertexShader9* pVertexShader;
+		HRESULT hr;
 			
-			hr = d3d9Device->CreateVertexShader( 
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				&pVertexShader);
+		hr = d3d9Device->CreateVertexShader( 
+			static_cast<DWORD*>(microcode->GetBufferPointer()), 
+			&pVertexShader);
 
-			if (FAILED(hr))
-			{
-				CM_EXCEPT(RenderingAPIException, "Cannot create D3D9 vertex shader from microcode");
-			}
-
-			mMapDeviceToVertexShader[d3d9Device] = pVertexShader;
-		}
-		else
+		if (FAILED(hr))
 		{
-			CM_EXCEPT(RenderingAPIException, "Specified D3D9 vertex shader is not supported!");
-
-			mMapDeviceToVertexShader[d3d9Device] = NULL;
+			CM_EXCEPT(RenderingAPIException, "Cannot create D3D9 vertex shader from microcode");
 		}
+
+		mMapDeviceToVertexShader[d3d9Device] = pVertexShader;
     }
-	//-----------------------------------------------------------------------------
+
 	void D3D9GpuVertexProgram::notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device)
 	{
 		
 	}
-	//-----------------------------------------------------------------------------
+
 	void D3D9GpuVertexProgram::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	{
 		DeviceToVertexShaderIterator it;
@@ -229,9 +302,11 @@ namespace BansheeEngine {
 		}
 	}
 
-	//-----------------------------------------------------------------------------
-	IDirect3DVertexShader9* D3D9GpuVertexProgram::getVertexShader( void )
+	IDirect3DVertexShader9* D3D9GpuVertexProgram::getVertexShader()
 	{
+		if (!isCompiled())
+			return nullptr;
+
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
 		DeviceToVertexShaderIterator it;
 
@@ -247,17 +322,18 @@ namespace BansheeEngine {
 	
 		return it->second;
 	}
-	//-----------------------------------------------------------------------------
-    D3D9GpuFragmentProgram::D3D9GpuFragmentProgram(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile) 
-		: D3D9GpuProgram(source, entryPoint, gptype, profile)       
+
+    D3D9GpuFragmentProgram::D3D9GpuFragmentProgram(const String& source, const String& entryPoint, 
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		: D3D9GpuProgram(source, entryPoint, GPT_FRAGMENT_PROGRAM, profile, includes, isAdjacencyInfoRequired)
     {
-        mType = GPT_FRAGMENT_PROGRAM;
+
     }
-	//-----------------------------------------------------------------------------
+
 	D3D9GpuFragmentProgram::~D3D9GpuFragmentProgram()
 	{
 	}
-	//-----------------------------------------------------------------------------
+
 	void D3D9GpuFragmentProgram::destroy_internal()
 	{
 		DeviceToPixelShaderIterator it = mMapDeviceToPixelShader.begin();
@@ -271,7 +347,7 @@ namespace BansheeEngine {
 
 		D3D9GpuProgram::destroy_internal();
 	}
-	//-----------------------------------------------------------------------------
+
     void D3D9GpuFragmentProgram::loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode)
     {
 		DeviceToPixelShaderIterator it = mMapDeviceToPixelShader.find(d3d9Device);
@@ -279,37 +355,23 @@ namespace BansheeEngine {
 		if (it != mMapDeviceToPixelShader.end())
 			SAFE_RELEASE(it->second);
 
-		if (isSupported())
-		{
-			// Create the shader
-			IDirect3DPixelShader9* pPixelShader;
-			HRESULT hr;
+		// Create the shader
+		IDirect3DPixelShader9* pPixelShader;
+		HRESULT hr;
 
-			hr = d3d9Device->CreatePixelShader(
-				static_cast<DWORD*>(microcode->GetBufferPointer()), 
-				&pPixelShader);
+		hr = d3d9Device->CreatePixelShader(static_cast<DWORD*>(microcode->GetBufferPointer()), &pPixelShader);
 
-			if (FAILED(hr))
-			{
-				CM_EXCEPT(RenderingAPIException, "Cannot create D3D9 pixel shader from microcode.");
-			}
+		if (FAILED(hr))
+			CM_EXCEPT(RenderingAPIException, "Cannot create D3D9 pixel shader from microcode.");
 
-			mMapDeviceToPixelShader[d3d9Device] = pPixelShader;
-		}
-		else
-		{
-			CM_EXCEPT(RenderingAPIException, "Specified D3D9 pixel shader is not supported!");
-
-			mMapDeviceToPixelShader[d3d9Device] = NULL;
-		}
+		mMapDeviceToPixelShader[d3d9Device] = pPixelShader;
     }
-	//-----------------------------------------------------------------------------
+
 	void D3D9GpuFragmentProgram::notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device)
 	{
 		
 	}
 
-	//-----------------------------------------------------------------------------
 	void D3D9GpuFragmentProgram::notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device)
 	{
 		DeviceToPixelShaderIterator it;
@@ -325,9 +387,11 @@ namespace BansheeEngine {
 		}
 	}
 
-	//-----------------------------------------------------------------------------
-	IDirect3DPixelShader9* D3D9GpuFragmentProgram::getPixelShader( void )
+	IDirect3DPixelShader9* D3D9GpuFragmentProgram::getPixelShader()
 	{
+		if (!isCompiled())
+			return nullptr;
+
 		IDirect3DDevice9* d3d9Device = D3D9RenderSystem::getActiveD3D9Device();
 		DeviceToPixelShaderIterator it;
 
@@ -343,7 +407,5 @@ namespace BansheeEngine {
 
 		return it->second;
 	}
-	//-----------------------------------------------------------------------------
-
 }
 

+ 0 - 60
CamelotD3D9Renderer/Source/CmD3D9GpuProgramManager.cpp

@@ -1,60 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmD3D9GpuProgramManager.h"
-#include "CmD3D9GpuProgram.h"
-#include "CmException.h"
-
-namespace BansheeEngine {
-    //-----------------------------------------------------------------------------
-    D3D9GpuProgramManager::D3D9GpuProgramManager()
-		:GpuProgramManager()
-    {
-
-    }
-    //-----------------------------------------------------------------------------
-    D3D9GpuProgramManager::~D3D9GpuProgramManager()
-    {
-
-    }
-    //-----------------------------------------------------------------------------
-    GpuProgramPtr D3D9GpuProgramManager::create(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile)
-    {
-        if (gptype == GPT_VERTEX_PROGRAM)
-        {
-            D3D9GpuVertexProgram* prog = new (cm_alloc<D3D9GpuVertexProgram, PoolAlloc>()) D3D9GpuVertexProgram(source, entryPoint, gptype, profile);
-
-			return cm_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
-        }
-        else
-        {
-            D3D9GpuFragmentProgram* prog = new (cm_alloc<D3D9GpuFragmentProgram, PoolAlloc>()) D3D9GpuFragmentProgram(source, entryPoint, gptype, profile);
-
-			return cm_core_ptr<D3D9GpuFragmentProgram, PoolAlloc>(prog);
-        }
-    }
-}

+ 0 - 267
CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp

@@ -1,267 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmD3D9HLSLProgram.h"
-#include "CmGpuProgramManager.h"
-#include "CmD3D9GpuProgram.h"
-#include "CmException.h"
-#include "CmRenderSystem.h"
-#include "CmAsyncOp.h"
-#include "CmGpuParams.h"
-#include "CmD3D9HLSLParamParser.h"
-#include "CmD3D9HLSLProgramRTTI.h"
-
-namespace BansheeEngine {
-	//-----------------------------------------------------------------------
-	D3D9HLSLProgram::D3D9HLSLProgram(const String& source, const String& entryPoint,
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
-		: HighLevelGpuProgram(source, entryPoint, gptype, profile, includes, isAdjacencyInfoRequired)
-		, mPreprocessorDefines()
-		, mColumnMajorMatrices(true)
-		, mpMicroCode(NULL)
-		, mOptimisationLevel(OPT_DEFAULT)
-	{
-	}
-	//-----------------------------------------------------------------------
-	D3D9HLSLProgram::~D3D9HLSLProgram()
-	{
-
-	}
-	//-----------------------------------------------------------------------
-	void D3D9HLSLProgram::initialize_internal()
-	{
-		if (isSupported())
-		{
-			// Populate preprocessor defines
-			String stringBuffer;
-
-			Vector<D3DXMACRO> defines;
-			const D3DXMACRO* pDefines = 0;
-			if (!mPreprocessorDefines.empty())
-			{
-				stringBuffer = mPreprocessorDefines;
-
-				// Split preprocessor defines and build up macro array
-				D3DXMACRO macro;
-				String::size_type pos = 0;
-				while (pos != String::npos)
-				{
-					macro.Name = &stringBuffer[pos];
-					macro.Definition = 0;
-
-					String::size_type start_pos=pos;
-
-					// Find delims
-					pos = stringBuffer.find_first_of(";,=", pos);
-
-					if(start_pos==pos)
-					{
-						if(pos==stringBuffer.length())
-						{
-							break;
-						}
-						pos++;
-						continue;
-					}
-
-					if (pos != String::npos)
-					{
-						// Check definition part
-						if (stringBuffer[pos] == '=')
-						{
-							// Setup null character for macro name
-							stringBuffer[pos++] = '\0';
-							macro.Definition = &stringBuffer[pos];
-							pos = stringBuffer.find_first_of(";,", pos);
-						}
-						else
-						{
-							// No definition part, define as "1"
-							macro.Definition = "1";
-						}
-
-						if (pos != String::npos)
-						{
-							// Setup null character for macro name or definition
-							stringBuffer[pos++] = '\0';
-						}
-					}
-					else
-					{
-						macro.Definition = "1";
-					}
-					if(strlen(macro.Name)>0)
-					{
-						defines.push_back(macro);
-					}
-					else
-					{
-						break;
-					}
-				}
-
-				// Add NULL terminator
-				macro.Name = 0;
-				macro.Definition = 0;
-				defines.push_back(macro);
-
-				pDefines = &defines[0];
-			}
-
-			// Populate compile flags
-			DWORD compileFlags = 0;
-			if (mColumnMajorMatrices)
-				compileFlags |= D3DXSHADER_PACKMATRIX_COLUMNMAJOR;
-			else
-				compileFlags |= D3DXSHADER_PACKMATRIX_ROWMAJOR;
-
-	#if CM_DEBUG_MODE
-			compileFlags |= D3DXSHADER_DEBUG;
-	#endif
-			switch (mOptimisationLevel)
-			{
-			case OPT_DEFAULT:
-				compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL1;
-				break;
-			case OPT_NONE:
-				compileFlags |= D3DXSHADER_SKIPOPTIMIZATION;
-				break;
-			case OPT_0:
-				compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL0;
-				break;
-			case OPT_1:
-				compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL1;
-				break;
-			case OPT_2:
-				compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL2;
-				break;
-			case OPT_3:
-				compileFlags |= D3DXSHADER_OPTIMIZATION_LEVEL3;
-				break;
-			}
-
-			LPD3DXBUFFER errors = 0;
-
-			// include handler
-			LPD3DXCONSTANTTABLE constTable;
-
-			String hlslProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
-
-			// Compile & assemble into microcode
-			HRESULT hr = D3DXCompileShader(
-				mSource.c_str(),
-				static_cast<UINT>(mSource.length()),
-				pDefines,
-				nullptr, 
-				mEntryPoint.c_str(),
-				hlslProfile.c_str(),
-				compileFlags,
-				&mpMicroCode,
-				&errors,
-				&constTable);
-
-			if (FAILED(hr))
-			{
-				String message = "Cannot assemble D3D9 high-level shader ";
-
-				if( errors )
-				{
-					message += String(" Errors:\n") + static_cast<const char*>(errors->GetBufferPointer());
-					errors->Release();
-				}
-
-				CM_EXCEPT(RenderingAPIException, message);
-			}
-
-			// Create a low-level program, give it the same name as us
-			mAssemblerProgram = 
-				GpuProgramManager::instance().createProgram(
-				"",// dummy source, since we'll be using microcode
-				"",
-				mType, 
-				mProfile);
-			static_cast<D3D9GpuProgram*>(mAssemblerProgram.get())->setExternalMicrocode(mpMicroCode);
-
-			D3D9HLSLParamParser paramParser(constTable);
-			mParametersDesc = paramParser.buildParameterDescriptions();
-
-			SAFE_RELEASE(constTable);
-		}
-
-		HighLevelGpuProgram::initialize_internal();
-	}
-    //-----------------------------------------------------------------------
-    void D3D9HLSLProgram::destroy_internal()
-    {
-        SAFE_RELEASE(mpMicroCode);
-        
-		HighLevelGpuProgram::destroy_internal();
-    }
-	//-----------------------------------------------------------------------
-	LPD3DXBUFFER D3D9HLSLProgram::getMicroCode()
-	{
-		return mpMicroCode;
-	}
-    //-----------------------------------------------------------------------
-    bool D3D9HLSLProgram::isSupported(void) const
-    {
-        if (!isRequiredCapabilitiesSupported())
-            return false;
-
-		String hlslProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
-
-		RenderSystem* rs = BansheeEngine::RenderSystem::instancePtr();
-		return rs->getCapabilities()->isShaderProfileSupported(hlslProfile);
-    }
-	//-----------------------------------------------------------------------
-	GpuParamsPtr D3D9HLSLProgram::createParameters()
-	{
-		GpuParamsPtr params = cm_shared_ptr<GpuParams, PoolAlloc>(std::ref(mParametersDesc), mColumnMajorMatrices);
-
-		return params;
-	}
-    //-----------------------------------------------------------------------
-    const String& D3D9HLSLProgram::getLanguage(void) const
-    {
-        static const String language = "hlsl";
-
-        return language;
-    }
-
-	/************************************************************************/
-	/* 								SERIALIZATION                      		*/
-	/************************************************************************/
-	RTTITypeBase* D3D9HLSLProgram::getRTTIStatic()
-	{
-		return D3D9HLSLProgramRTTI::instance();
-	}
-
-	RTTITypeBase* D3D9HLSLProgram::getRTTI() const
-	{
-		return D3D9HLSLProgram::getRTTIStatic();
-	}
-}

+ 33 - 47
CamelotD3D9Renderer/Source/CmD3D9HLSLProgramFactory.cpp

@@ -1,64 +1,50 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
 #include "CmD3D9HLSLProgramFactory.h"
 #include "CmString.h"
-#include "CmD3D9HLSLProgram.h"
+#include "CmD3D9GpuProgram.h"
+
+namespace BansheeEngine
+{
+    String D3D9HLSLProgramFactory::LANGUAGE_NAME = "hlsl";
 
-namespace BansheeEngine {
-    //-----------------------------------------------------------------------
-    String D3D9HLSLProgramFactory::sLanguageName = "hlsl";
-    //-----------------------------------------------------------------------
     D3D9HLSLProgramFactory::D3D9HLSLProgramFactory()
     {
     }
-    //-----------------------------------------------------------------------
+
     D3D9HLSLProgramFactory::~D3D9HLSLProgramFactory()
     {
     }
-    //-----------------------------------------------------------------------
-    const String& D3D9HLSLProgramFactory::getLanguage(void) const
+
+    const String& D3D9HLSLProgramFactory::getLanguage() const
     {
-        return sLanguageName;
+        return LANGUAGE_NAME;
     }
-    //-----------------------------------------------------------------------
-	HighLevelGpuProgramPtr D3D9HLSLProgramFactory::create(const String& source, const String& entryPoint, 
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes)
-    {
-		D3D9HLSLProgram* prog = new (cm_alloc<D3D9HLSLProgram, PoolAlloc>()) D3D9HLSLProgram(source, entryPoint, gptype, profile, includes);
 
-        return cm_core_ptr<D3D9HLSLProgram, PoolAlloc>(prog);
+	GpuProgramPtr D3D9HLSLProgramFactory::create(const String& source, const String& entryPoint, 
+		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacency)
+    {
+		if (gptype == GPT_VERTEX_PROGRAM)
+		{
+			D3D9GpuVertexProgram* prog = new (cm_alloc<D3D9GpuVertexProgram, PoolAlloc>()) 
+				D3D9GpuVertexProgram(source, entryPoint, profile, includes, requiresAdjacency);
+
+			return cm_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
+		}
+		else if (gptype == GPT_FRAGMENT_PROGRAM)
+		{
+			D3D9GpuFragmentProgram* prog = new (cm_alloc<D3D9GpuFragmentProgram, PoolAlloc>())
+				D3D9GpuFragmentProgram(source, entryPoint, profile, includes, requiresAdjacency);
+
+			return cm_core_ptr<D3D9GpuFragmentProgram, PoolAlloc>(prog);
+		}
+
+		return nullptr;
     }
-	//-----------------------------------------------------------------------
-	HighLevelGpuProgramPtr D3D9HLSLProgramFactory::create()
+
+	GpuProgramPtr D3D9HLSLProgramFactory::create()
 	{
-		D3D9HLSLProgram* prog = new (cm_alloc<D3D9HLSLProgram, PoolAlloc>()) D3D9HLSLProgram("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
+		D3D9GpuVertexProgram* prog = new (cm_alloc<D3D9GpuVertexProgram, PoolAlloc>())
+			D3D9GpuVertexProgram("", "", GPP_NONE, nullptr);
 
-		return cm_core_ptr<D3D9HLSLProgram, PoolAlloc>(prog);
+		return cm_core_ptr<D3D9GpuVertexProgram, PoolAlloc>(prog);
 	}
 }

+ 4 - 9
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -40,13 +40,12 @@ THE SOFTWARE.
 #include "CmD3D9VertexBuffer.h"
 #include "CmD3D9VertexDeclaration.h"
 #include "CmD3D9GpuProgram.h"
-#include "CmD3D9GpuProgramManager.h"
 #include "CmD3D9HLSLProgramFactory.h"
 #include "CmD3D9OcclusionQuery.h"
 #include "CmD3D9DeviceManager.h"
 #include "CmD3D9ResourceManager.h"
 #include "CmD3D9RenderWindowManager.h"
-#include "CmHighLevelGpuProgramManager.h"
+#include "CmGpuProgramManager.h"
 #include "CmRenderStateManager.h"
 #include "CmAsyncOp.h"
 #include "CmBlendState.h"
@@ -152,9 +151,6 @@ namespace BansheeEngine
 		// Also create hardware buffer manager		
 		HardwareBufferManager::startUp(cm_new<D3D9HardwareBufferManager>());
 
-		// Create the GPU program manager		
-		GpuProgramManager::startUp(cm_new<D3D9GpuProgramManager>());
-
 		// Create & register HLSL factory		
 		mHLSLProgramFactory = cm_new<D3D9HLSLProgramFactory>();
 
@@ -206,14 +202,13 @@ namespace BansheeEngine
 		QueryManager::shutDown();
 		TextureManager::shutDown();
 		HardwareBufferManager::shutDown();
-		GpuProgramManager::shutDown();	
 		RenderWindowManager::shutDown();
 		RenderStateManager::shutDown();
 
 		// Deleting the HLSL program factory
 		if (mHLSLProgramFactory)
 		{
-			HighLevelGpuProgramManager::instance().removeFactory(mHLSLProgramFactory);
+			GpuProgramManager::instance().removeFactory(mHLSLProgramFactory);
 			cm_delete(mHLSLProgramFactory);
 			mHLSLProgramFactory = 0;
 		}
@@ -262,7 +257,7 @@ namespace BansheeEngine
 		if(!prg.isLoaded())
 			return;
 
-		GpuProgramPtr bindingPrg = prg->getBindingDelegate();
+		GpuProgramPtr bindingPrg = std::static_pointer_cast<GpuProgram>(prg->getThisPtr());
 
 		HRESULT hr;
 		switch (bindingPrg->getType())
@@ -2235,7 +2230,7 @@ namespace BansheeEngine
 		}
 
 		if (caps->isShaderProfileSupported("hlsl"))
-			HighLevelGpuProgramManager::instance().addFactory(mHLSLProgramFactory);
+			GpuProgramManager::instance().addFactory(mHLSLProgramFactory);
 
 		mNumTexStages = caps->getNumCombinedTextureUnits();
 		mTexStageDesc = cm_newN<sD3DTextureStageDesc>(mNumTexStages);

+ 1 - 7
CamelotGLRenderer/CamelotGLRenderer.vcxproj

@@ -239,7 +239,6 @@
     <ClInclude Include="Include\CmGLFrameBufferObject.h" />
     <ClInclude Include="Include\CmGLGpuBuffer.h" />
     <ClInclude Include="Include\CmGLGpuParamBlockBuffer.h" />
-    <ClInclude Include="Include\CmGLGpuProgramManager.h" />
     <ClInclude Include="Include\CmGLHardwareBufferManager.h" />
     <ClInclude Include="Include\CmGLIndexBuffer.h" />
     <ClInclude Include="Include\CmGLOcclusionQuery.h" />
@@ -254,7 +253,7 @@
     <ClInclude Include="Include\CmGLRenderSystemFactory.h" />
     <ClInclude Include="Include\CmGLRenderTexture.h" />
     <ClInclude Include="Include\CmGLRenderWindowManager.h" />
-    <ClInclude Include="Include\CmGLSLProgramRTTI.h" />
+    <ClInclude Include="Include\CmGLSLGpuProgramRTTI.h" />
     <ClInclude Include="Include\CmGLSupport.h" />
     <ClInclude Include="Include\CmGLTexture.h" />
     <ClInclude Include="Include\CmGLTextureManager.h" />
@@ -262,11 +261,9 @@
     <ClInclude Include="Include\CmWin32GLSupport.h" />
     <ClInclude Include="Include\CmWin32Prerequisites.h" />
     <ClInclude Include="Include\CmWin32Window.h" />
-    <ClInclude Include="Source\GLSL\include\CmGLSLExtSupport.h" />
     <ClInclude Include="Source\GLSL\include\CmGLSLGpuProgram.h" />
     <ClInclude Include="Source\GLSL\include\CmGLSLParamParser.h" />
     <ClInclude Include="Source\GLSL\include\CmGLSLPreprocessor.h" />
-    <ClInclude Include="Source\GLSL\include\CmGLSLProgram.h" />
     <ClInclude Include="Source\GLSL\include\CmGLSLProgramFactory.h" />
     <ClInclude Include="Source\GLSL\include\CmGLSLProgramPipelineManager.h" />
     <ClInclude Include="Source\win32\CmGLUtil.h" />
@@ -278,7 +275,6 @@
     <ClCompile Include="Source\CmGLFrameBufferObject.cpp" />
     <ClCompile Include="Source\CmGLGpuBuffer.cpp" />
     <ClCompile Include="Source\CmGLGpuParamBlockBuffer.cpp" />
-    <ClCompile Include="Source\CmGLGpuProgramManager.cpp" />
     <ClCompile Include="Source\CmGLHardwareBufferManager.cpp" />
     <ClCompile Include="Source\CmGLIndexBuffer.cpp" />
     <ClCompile Include="Source\CmGLOcclusionQuery.cpp" />
@@ -298,10 +294,8 @@
     <ClCompile Include="Source\CmWin32GLSupport.cpp" />
     <ClCompile Include="Source\CmWin32Window.cpp" />
     <ClCompile Include="Source\glew.cpp" />
-    <ClCompile Include="Source\GLSL\src\CmGLSLExtSupport.cpp" />
     <ClCompile Include="Source\GLSL\src\CmGLSLGpuProgram.cpp" />
     <ClCompile Include="Source\GLSL\src\CmGLSLPreprocessor.cpp" />
-    <ClCompile Include="Source\GLSL\src\CmGLSLProgram.cpp" />
     <ClCompile Include="Source\GLSL\src\CmGLSLProgramFactory.cpp" />
     <ClCompile Include="Source\GLSL\src\CmGLSLProgramPipelineManager.cpp" />
     <ClCompile Include="Source\win32\CmWin32Context.cpp" />

+ 66 - 78
CamelotGLRenderer/CamelotGLRenderer.vcxproj.filters

@@ -13,15 +13,21 @@
       <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
       <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
     </Filter>
-    <Filter Include="GLSL">
-      <UniqueIdentifier>{23f5e949-4542-49d4-86f9-d24656b5de08}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Win32">
-      <UniqueIdentifier>{c85ecca8-4719-49f1-879b-93a27c8da4aa}</UniqueIdentifier>
-    </Filter>
     <Filter Include="Header Files\RTTI">
       <UniqueIdentifier>{f65cdae4-61c9-4f4f-a4af-9fc39a49704d}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Header Files\GLSL">
+      <UniqueIdentifier>{4a04e68e-bddd-41da-a32c-b50d628cd689}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Win32">
+      <UniqueIdentifier>{e5ed7756-6562-4fda-b111-fbc35d54fb7c}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Win32">
+      <UniqueIdentifier>{ba3de2cb-a789-41d9-918b-ecffa74967c3}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\GLSL">
+      <UniqueIdentifier>{5a08232d-f612-44f5-b9f5-3bad262a935c}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\CmGLContext.h">
@@ -30,9 +36,6 @@
     <ClInclude Include="Include\CmGLFrameBufferObject.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmGLGpuProgramManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmGLHardwareBufferManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -60,51 +63,12 @@
     <ClInclude Include="Include\CmGLTextureManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmWin32Context.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmWin32GLSupport.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmWin32Prerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmWin32Window.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\CmGLSLExtSupport.h">
-      <Filter>GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\CmGLSLGpuProgram.h">
-      <Filter>GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\CmGLSLPreprocessor.h">
-      <Filter>GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\CmGLSLProgram.h">
-      <Filter>GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\CmGLSLProgramFactory.h">
-      <Filter>GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\win32\CmGLUtil.h">
-      <Filter>Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmGLSLProgramRTTI.h">
-      <Filter>Header Files\RTTI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmGLRenderWindowManager.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="Include\CmGLMultiRenderTexture.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Source\GLSL\include\CmGLSLParamParser.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\CmGLSLProgramPipelineManager.h">
-      <Filter>GLSL</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmGLOcclusionQuery.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -132,35 +96,47 @@
     <ClInclude Include="Include\CmGLTimerQuery.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmGLSLGpuProgramRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\CmGLSLGpuProgram.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\CmGLSLParamParser.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\CmGLSLPreprocessor.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\CmGLSLProgramFactory.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\CmGLSLProgramPipelineManager.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmWin32Context.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\win32\CmGLUtil.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmWin32GLSupport.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmWin32Prerequisites.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmWin32Window.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="Source\GLSL\src\CmGLSLExtSupport.cpp">
-      <Filter>GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\GLSL\src\CmGLSLGpuProgram.cpp">
-      <Filter>GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\GLSL\src\CmGLSLPreprocessor.cpp">
-      <Filter>GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\GLSL\src\CmGLSLProgram.cpp">
-      <Filter>GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\GLSL\src\CmGLSLProgramFactory.cpp">
-      <Filter>GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\win32\CmWin32Context.cpp">
-      <Filter>Win32</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmGLContext.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="Source\CmGLFrameBufferObject.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmGLGpuProgramManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmGLHardwareBufferManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -185,12 +161,6 @@
     <ClCompile Include="Source\CmGLTextureManager.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmWin32GLSupport.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\CmWin32Window.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\glew.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -203,9 +173,6 @@
     <ClCompile Include="Source\CmGLMultiRenderTexture.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\GLSL\src\CmGLSLProgramPipelineManager.cpp">
-      <Filter>GLSL</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmGLIndexBuffer.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -233,5 +200,26 @@
     <ClCompile Include="Source\CmGLTimerQuery.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\GLSL\src\CmGLSLGpuProgram.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\GLSL\src\CmGLSLPreprocessor.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\GLSL\src\CmGLSLProgramFactory.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\GLSL\src\CmGLSLProgramPipelineManager.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\win32\CmWin32Context.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmWin32GLSupport.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmWin32Window.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 0 - 50
CamelotGLRenderer/Include/CmGLGpuProgramManager.h

@@ -1,50 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#ifndef __GLGpuProgramManager_H__
-#define __GLGpuProgramManager_H__
-
-#include "CmGLPrerequisites.h"
-#include "CmGpuProgramManager.h"
-
-namespace BansheeEngine 
-{
-	class CM_RSGL_EXPORT GLGpuProgramManager : public GpuProgramManager
-	{
-		public:
-			GLGpuProgramManager();
-			~GLGpuProgramManager();
-
-		protected:
-			/// Specialised create method with specific parameters
-			GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile);
-	};
-
-};
-
-#endif //__GLGpuProgramManager_H__

+ 1 - 1
CamelotGLRenderer/Include/CmGLPrerequisites.h

@@ -54,7 +54,7 @@ namespace BansheeEngine
 
 	enum TypeID_D3D9
 	{
-		TID_GL_GLSLProgram = 11000
+		TID_GL_GLSLGpuProgram = 11000
 	};
 }
 

+ 0 - 1
CamelotGLRenderer/Include/CmGLRenderSystem.h

@@ -3,7 +3,6 @@
 #include "CmGLPrerequisites.h"
 #include "CmRenderSystem.h"
 #include "CmGLHardwareBufferManager.h"
-#include "CmGLGpuProgramManager.h"
 #include "CmGLSLProgramFactory.h"
 #include "CmVector4.h"
 

+ 0 - 33
CamelotGLRenderer/Include/CmGLSLProgramRTTI.h

@@ -1,33 +0,0 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmRTTIType.h"
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmHighLevelGpuProgram.h"
-#include "CmGLSLProgram.h"
-
-namespace BansheeEngine
-{
-	class CM_RSGL_EXPORT GLSLProgramRTTI : public RTTIType<GLSLProgram, HighLevelGpuProgram, GLSLProgramRTTI>
-	{
-	public:
-		GLSLProgramRTTI()
-		{ }
-
-		virtual const String& getRTTIName()
-		{
-			static String name = "GLSLProgram";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId()
-		{
-			return TID_GL_GLSLProgram;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject()
-		{
-			return HighLevelGpuProgramManager::instance().createEmpty("glsl");
-		}
-	};
-}

+ 0 - 50
CamelotGLRenderer/Source/CmGLGpuProgramManager.cpp

@@ -1,50 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#include "CmGLGpuProgramManager.h"
-#include "CmGLSLGpuProgram.h"
-#include "CmException.h"
-
-namespace BansheeEngine
-{
-	GLGpuProgramManager::GLGpuProgramManager()
-	{
-		// Superclass sets up members 
-	}
-
-	GLGpuProgramManager::~GLGpuProgramManager()
-	{
-	}
-
-	GpuProgramPtr GLGpuProgramManager::create(const String& source, const String& entryPoint, GpuProgramType gptype, GpuProgramProfile profile)
-	{
-		GLSLGpuProgram* prog = new (cm_alloc<GLSLGpuProgram, PoolAlloc>()) GLSLGpuProgram(source, entryPoint, gptype, profile, nullptr);
-
-		return cm_core_ptr<GLSLGpuProgram, PoolAlloc>(prog);
-	}
-}

+ 6 - 12
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -5,10 +5,7 @@
 #include "CmGLIndexBuffer.h"
 #include "CmGLUtil.h"
 #include "CmGLSLGpuProgram.h"
-#include "CmGLSLProgram.h"
-#include "CmGLGpuProgramManager.h"
 #include "CmException.h"
-#include "CmGLSLExtSupport.h"
 #include "CmGLOcclusionQuery.h"
 #include "CmGLContext.h"
 #include "CmGLSupport.h"
@@ -160,13 +157,12 @@ namespace BansheeEngine
 		if (mGLSLProgramFactory)
 		{
 			// Remove from manager safely
-			HighLevelGpuProgramManager::instance().removeFactory(mGLSLProgramFactory);
+			GpuProgramManager::instance().removeFactory(mGLSLProgramFactory);
 			cm_delete(mGLSLProgramFactory);
 			mGLSLProgramFactory = nullptr;
 		}
 
-		// Deleting the GPU program manager and hardware buffer manager.  Has to be done before the mGLSupport->stop().
-		GpuProgramManager::shutDown();
+		// Deleting the hardware buffer manager.  Has to be done before the mGLSupport->stop().
 		HardwareBufferManager::shutDown();
 		GLRTTManager::shutDown();
 
@@ -203,8 +199,7 @@ namespace BansheeEngine
 	{
 		THROW_IF_NOT_CORE_THREAD;
 
-		GpuProgramPtr bindingPrg = prg->getBindingDelegate();
-		GLSLGpuProgramPtr glprg = std::static_pointer_cast<GLSLGpuProgram>(bindingPrg);
+		GLSLGpuProgramPtr glprg = std::static_pointer_cast<GLSLGpuProgram>(prg->getThisPtr());
 
 		switch (glprg->getType())
 		{
@@ -265,7 +260,7 @@ namespace BansheeEngine
 		bindableParams.updateHardwareBuffers();
 		const GpuParamDesc& paramDesc = bindableParams.getParamDesc();
 		GLSLGpuProgramPtr activeProgram = getActiveProgram(gptype);
-		GLuint glProgram = activeProgram->getGLSLProgram()->getGLHandle();
+		GLuint glProgram = activeProgram->getGLHandle();
 
 		for(auto iter = paramDesc.textures.begin(); iter != paramDesc.textures.end(); ++iter)
 		{
@@ -1315,7 +1310,7 @@ namespace BansheeEngine
 		VertexDeclaration::VertexElementList::const_iterator elem, elemEnd;
 		elemEnd = decl.end();
 
-		const VertexDeclaration::VertexElementList& inputAttributes = mCurrentVertexProgram->getGLSLProgram()->getInputAttributes().getElements();
+		const VertexDeclaration::VertexElementList& inputAttributes = mCurrentVertexProgram->getInputAttributes().getElements();
 
 		GLuint VAOID[1];
 		glGenVertexArrays(1, &VAOID[0]);
@@ -1703,13 +1698,12 @@ namespace BansheeEngine
 		checkForErrors();
 
 		// GPU Program Manager setup
-		GpuProgramManager::startUp(cm_new<GLGpuProgramManager>());
 		checkForErrors();
 
 		if(caps->isShaderProfileSupported("glsl"))
 		{
 			mGLSLProgramFactory = cm_new<GLSLProgramFactory>();
-			HighLevelGpuProgramManager::instance().addFactory(mGLSLProgramFactory);
+			GpuProgramManager::instance().addFactory(mGLSLProgramFactory);
 			checkForErrors();
 		}
 

+ 0 - 78
CamelotGLRenderer/Source/GLSL/include/CmGLSLExtSupport.h

@@ -1,78 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-
-
-#ifndef __GLSLExtSupport_H__
-#define __GLSLExtSupport_H__
-
-#include "CmGLPrerequisites.h"
-
-//
-// OpenGL Shading Language entry points
-//
-namespace BansheeEngine
-{
-	enum GLSLObjectType
-	{
-		GLSLOT_SHADER,
-		GLSLOT_PROGRAM
-	};
-
-	// forward declarations
-	class GLSLProgram;
-	class GLSLGpuProgram;
-	class GLSLLinkProgram;
-	class GLSLLinkProgramManager;
-	class GLSLProgramFactory;
-
-
-	/** Check for GL errors and report them in the Ogre Log.
-
-	@param forceInfoLog if true then message from GL info log is obtained
-	@param forceException if true then exception is generated if a GL error found
-	*/
-    void checkForGLSLError(const String& ogreMethod, const String& errorTextPrefix, const GLuint obj, GLSLObjectType objectType, 
-		const bool forceInfoLog = false, const bool forceException = false);
-
-	/** if there is a message in GL info log then post it in the engine Log
-	@param msg the info log message string is appended to this string
-	@param obj the GL shader object that is used to retrieve the info log
-	*/
-	bool logShaderInfo(String& msg, const GLuint obj);
-
-	/** if there is a message in GL info log then post it in the engine Log
-	@param msg the info log message string is appended to this string
-	@param obj the GL program object that is used to retrieve the info log
-	*/
-	bool logProgramInfo(String& msg, const GLuint obj);
-
-
-}
-
-#endif // __GLSLExtSupport_H__

+ 83 - 50
CamelotGLRenderer/Source/GLSL/include/CmGLSLGpuProgram.h

@@ -1,36 +1,6 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#ifndef __GLSLGpuProgram_H__
-#define __GLSLGpuProgram_H__
-
-// Precompiler options
-#include "CmGLSLExtSupport.h"
+#pragma once
+
+#include "CmGLPrerequisites.h"
 #include "CmGpuProgram.h"
 
 namespace BansheeEngine {
@@ -49,25 +19,86 @@ namespace BansheeEngine {
 	public:
 		~GLSLGpuProgram();
 
-		/// get the GLSLProgram for the shader object
-		GLSLProgram* getGLSLProgram(void) const { return mGLSLProgram; }
+		const GLuint getGLHandle() const { return mGLHandle; }
+
+		/** Sets the preprocessor defines use to compile the program. */
+		void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
+		/** Sets the preprocessor defines use to compile the program. */
+		const String& getPreprocessorDefines() const { return mPreprocessorDefines; }
+
+		/// Overridden from GpuProgram
+		const String& getLanguage() const;
+
+		/** Returns the operation type that this geometry program expects to
+		receive as input
+		*/
+		virtual DrawOperationType getInputOperationType() const
+		{
+			return mInputOperationType;
+		}
+		/** Returns the operation type that this geometry program will emit
+		*/
+		virtual DrawOperationType getOutputOperationType() const
+		{
+			return mOutputOperationType;
+		}
+		/** Returns the maximum number of vertices that this geometry program can
+		output in a single run
+		*/
+		virtual int getMaxOutputVertices() const { return mMaxOutputVertices; }
+
+		/** Sets the operation type that this geometry program expects to receive
+		*/
+		virtual void setInputOperationType(DrawOperationType operationType)
+		{
+			mInputOperationType = operationType;
+		}
+		/** Set the operation type that this geometry program will emit
+		*/
+		virtual void setOutputOperationType(DrawOperationType operationType)
+		{
+			mOutputOperationType = operationType;
+		}
+		/** Set the maximum number of vertices that a single run of this geometry program
+		can emit.
+		*/
+		virtual void setMaxOutputVertices(int maxOutputVertices)
+		{
+			mMaxOutputVertices = maxOutputVertices;
+		}
+
+		const VertexDeclaration& getInputAttributes() const { return *mVertexDeclaration; }
 
-		void setGLSLProgram(GLSLProgram* program) { mGLSLProgram = program; }
-		
 		/// Get the assigned GL program id
-		const UINT32 getProgramID(void) const { return mProgramID; }
-
-		bool isSupported() const;
+		const UINT32 getProgramID() const { return mProgramID; }
 
 	private:
-		friend class GLGpuProgramManager;
+		friend class GLSLProgramFactory;
+
+		GLSLGpuProgram(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired);
 
-		GLSLGpuProgram(const String& source, const String& entryPoint, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
+		/**
+		* @copydoc GpuProgram::initialize_internal()
+		*/
+		void initialize_internal();
 
-		/// GL Handle for the shader object
-		GLSLProgram* mGLSLProgram;
+		/**
+		* @copydoc GpuProgram::destroy_internal()
+		*/
+		void destroy_internal();
+
+	private:
+		UINT32 mProgramID;
+		GLuint mGLHandle;
 
+		DrawOperationType mInputOperationType;
+		DrawOperationType mOutputOperationType;
+		int mMaxOutputVertices;
+
+		String mPreprocessorDefines;
+		VertexDeclarationPtr mVertexDeclaration;
+		
 		/// keep track of the number of vertex shaders created
 		static UINT32 mVertexShaderCount;
 		/// keep track of the number of fragment shaders created
@@ -79,10 +110,12 @@ namespace BansheeEngine {
 		/// keep track of the number of domain shaders created
 		static UINT32 mDomainShaderCount;
 
-		UINT32 mProgramID;
-		GLenum mProgramType;
+		/************************************************************************/
+		/* 								SERIALIZATION                      		*/
+		/************************************************************************/
+	public:
+		friend class GLSLGpuProgramRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const;
     };
 }
-
-
-#endif // __GLSLGpuProgram_H__

+ 0 - 145
CamelotGLRenderer/Source/GLSL/include/CmGLSLProgram.h

@@ -1,145 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __GLSLProgram_H__
-#define __GLSLProgram_H__
-
-#include "CmGLPrerequisites.h"
-#include "CmHighLevelGpuProgram.h"
-
-namespace BansheeEngine {
-    /** Specialisation of HighLevelGpuProgram to provide support for OpenGL 
-        Shader Language (GLSL).
-    @remarks
-		GLSL has no target assembler or entry point specification like DirectX 9 HLSL.
-		Vertex and Fragment shaders only have one entry point called "main".  
-		When a shader is compiled, microcode is generated but can not be accessed by
-		the application.
-		GLSL also does not provide assembler low level output after compiling.  The GL Render
-		system assumes that the Gpu program is a GL Gpu program so GLSLProgram will create a 
-		GLSLGpuProgram that is subclassed from GLGpuProgram for the low level implementation.
-		The GLSLProgram class will create a shader object and compile the source but will
-		not create a program object.  It's up to GLSLGpuProgram class to request a program object
-		to link the shader object to.
-
-	@note
-		GLSL supports multiple modular shader objects that can be attached to one program
-		object to form a single shader.  This is supported through the "attach" material script
-		command.  All the modules to be attached are listed on the same line as the attach command
-		seperated by white space.
-        
-    */
-    class CM_RSGL_EXPORT GLSLProgram : public HighLevelGpuProgram
-    {
-    public:
-		~GLSLProgram();
-
-		const GLuint getGLHandle() const { return mGLHandle; }
-
-		/** Sets the preprocessor defines use to compile the program. */
-		void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
-		/** Sets the preprocessor defines use to compile the program. */
-		const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
-
-        /// Overridden from GpuProgram
-        const String& getLanguage(void) const;
-
-		/** Returns the operation type that this geometry program expects to
-			receive as input
-		*/
-		virtual DrawOperationType getInputOperationType(void) const 
-		{ return mInputOperationType; }
-		/** Returns the operation type that this geometry program will emit
-		*/
-		virtual DrawOperationType getOutputOperationType(void) const 
-		{ return mOutputOperationType; }
-		/** Returns the maximum number of vertices that this geometry program can
-			output in a single run
-		*/
-		virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; }
-
-		/** Sets the operation type that this geometry program expects to receive
-		*/
-		virtual void setInputOperationType(DrawOperationType operationType) 
-		{ mInputOperationType = operationType; }
-		/** Set the operation type that this geometry program will emit
-		*/
-		virtual void setOutputOperationType(DrawOperationType operationType) 
-		{ mOutputOperationType = operationType; }
-		/** Set the maximum number of vertices that a single run of this geometry program
-			can emit.
-		*/
-		virtual void setMaxOutputVertices(int maxOutputVertices) 
-		{ mMaxOutputVertices = maxOutputVertices; }
-
-		const VertexDeclaration& getInputAttributes() const { return *mVertexDeclaration; }
-
-		bool isSupported() const;
-
-	protected:
-		friend class GLSLProgramFactory;
-
-		GLSLProgram(const String& source, const String& entryPoint, 
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, 
-			bool isAdjacencyInfoRequired = false);
-
-		/**
-		 * @copydoc HighLevelGpuProgram::initialize_internal()
-		 */
-        void initialize_internal();
-
-		/**
-		 * @copydoc HighLevelGpuProgram::destroy_internal()
-		 */
-		void destroy_internal();
-
-	private:
-		/// GL handle for shader object
-		GLuint mGLHandle;
-		/// flag indicating if shader object successfully compiled
-		GLint mCompiled;
-		/// The input operation type for this (geometry) program
-		DrawOperationType mInputOperationType;
-		/// The output operation type for this (geometry) program
-		DrawOperationType mOutputOperationType;
-		/// The maximum amount of vertices that this (geometry) program can output
-		int mMaxOutputVertices;
-		/// Preprocessor options
-		String mPreprocessorDefines;
-		VertexDeclarationPtr mVertexDeclaration;
-
-		/************************************************************************/
-		/* 								SERIALIZATION                      		*/
-		/************************************************************************/
-	public:
-		friend class GLSLProgramRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const;
-    };
-}
-
-#endif // __GLSLProgram_H__

+ 12 - 43
CamelotGLRenderer/Source/GLSL/include/CmGLSLProgramFactory.h

@@ -1,53 +1,22 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
+#pragma once
 
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-
-#ifndef __GLSLProgramFactory_H__
-#define __GLSLProgramFactory_H__
-
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmGLSLExtSupport.h"
+#include "CmGLPrerequisites.h"
+#include "CmGpuProgramManager.h"
 
 namespace BansheeEngine
 {
     /** Factory class for GLSL programs. */
-    class CM_RSGL_EXPORT GLSLProgramFactory : public HighLevelGpuProgramFactory
+    class CM_RSGL_EXPORT GLSLProgramFactory : public GpuProgramFactory
     {
-    protected:
-		static String sLanguageName;
     public:
 		/// Get the name of the language this factory creates programs for
-		const String& getLanguage(void) const;
+		const String& getLanguage() const;
 		/// create an instance of GLSLProgram
-        HighLevelGpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
-			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes);
-		HighLevelGpuProgramPtr create();
-    };
-}
+        GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requireAdjacency);
+		GpuProgramPtr create();
 
-#endif // __GLSLProgramFactory_H__
+	protected:
+		static const String LANGUAGE_NAME;
+    };
+}

+ 0 - 138
CamelotGLRenderer/Source/GLSL/src/CmGLSLExtSupport.cpp

@@ -1,138 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#include "CmGLSLExtSupport.h"
-#include "CmGLSupport.h"
-#include "CmDebug.h"
-
-namespace BansheeEngine
-{
-    void checkForGLSLError(const String& ogreMethod, const String& errorTextPrefix, const GLuint obj, 
-		GLSLObjectType objectType, const bool forceInfoLog, const bool forceException)
-    {
-		GLenum glErr;
-		bool errorsFound = false;
-		String msg = errorTextPrefix;
-
-		// get all the GL errors
-		glErr = glGetError();
-		while (glErr != GL_NO_ERROR)
-        {
-			const char* glerrStr = (const char*)gluErrorString(glErr);
-			if (glerrStr)
-			{
-				msg += String(glerrStr);
-			}
-			glErr = glGetError();
-			errorsFound = true;
-        }
-
-
-		// if errors were found then put them in the Log and raise and exception
-		if (errorsFound || forceInfoLog)
-		{
-			// if shader or program object then get the log message and send to the log manager
-			bool infoLogMessageExists = false;
-			if(objectType == GLSLOT_SHADER)
-				infoLogMessageExists = logShaderInfo(msg, obj);
-			else if(objectType == GLSLOT_PROGRAM)
-				infoLogMessageExists = logProgramInfo(msg, obj);
-
-            if (forceException) 
-			{
-				CM_EXCEPT(InternalErrorException, msg);
-			}
-			else
-			{
-				if(errorsFound)
-				{
-					LOGWRN(msg);
-				}
-				else if(infoLogMessageExists)
-				{
-					LOGINFO(msg);
-				}
-			}
-		}
-    }
-
-	bool logShaderInfo(String& msg, const GLuint obj)
-	{
-		if (obj > 0)
-		{
-			GLint infologLength = 0;
-
-			glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &infologLength);
-
-			if (infologLength > 0)
-			{
-				GLint charsWritten  = 0;
-
-				GLchar* infoLog = (GLchar*)cm_alloc<ScratchAlloc>(sizeof(GLchar) * infologLength);
-
-				glGetShaderInfoLog(obj, infologLength, &charsWritten, infoLog);
-				msg += String(infoLog);
-
-				cm_free<ScratchAlloc>(infoLog);
-
-				if(charsWritten > 0)
-					return true;
-			}
-		}
-
-		return false;
-	}
-
-	bool logProgramInfo(String& msg, const GLuint obj)
-	{
-		if (obj > 0)
-		{
-			GLint infologLength = 0;
-
-			glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &infologLength);
-
-			if (infologLength > 0)
-			{
-				GLint charsWritten  = 0;
-
-				GLchar* infoLog = (GLchar*)cm_alloc<ScratchAlloc>(sizeof(GLchar) * infologLength);
-
-				glGetProgramInfoLog(obj, infologLength, &charsWritten, infoLog);
-				msg += String(infoLog);
-
-				cm_free<ScratchAlloc>(infoLog);
-
-				if(charsWritten > 0)
-					return true;
-			}
-		}
-
-		return false;
-	}
-
-}

+ 202 - 49
CamelotGLRenderer/Source/GLSL/src/CmGLSLGpuProgram.cpp

@@ -1,36 +1,12 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#include "CmGLSLExtSupport.h"
+#pragma once
+
 #include "CmGLSLGpuProgram.h"
-#include "CmGLSLProgram.h"
 #include "CmRenderSystem.h"
 #include "CmException.h"
+#include "CmGLSLPreprocessor.h"
+#include "CmGLSLParamParser.h"
+#include "CmHardwareBufferManager.h"
+#include "CmGLSLGpuProgramRTTI.h"
 
 namespace BansheeEngine {
 
@@ -39,44 +15,221 @@ namespace BansheeEngine {
 	UINT32 GLSLGpuProgram::mGeometryShaderCount = 0;
 	UINT32 GLSLGpuProgram::mDomainShaderCount = 0;
 	UINT32 GLSLGpuProgram::mHullShaderCount = 0;
-    //-----------------------------------------------------------------------------
-	GLSLGpuProgram::GLSLGpuProgram(const String& source, const String& entryPoint,
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes) 
-		:GpuProgram(source, entryPoint, gptype, profile, includes)
+
+	bool checkForGLSLError(const GLuint programObj, String& outErrorMsg)
+	{
+		StringStream stream;
+
+		GLenum glErr;
+		bool errorsFound = false;
+
+		glErr = glGetError();
+		while (glErr != GL_NO_ERROR)
+		{
+			const char* glerrStr = (const char*)gluErrorString(glErr);
+
+			if (glerrStr)
+			{
+				if (errorsFound)
+					stream << "\nPrevious errors: \n";
+
+				stream << String(glerrStr) << std::endl;;
+			}
+
+			glErr = glGetError();
+			errorsFound = true;
+		}
+
+		if (errorsFound && programObj > 0)
+		{
+			GLint infologLength = 0;
+			glGetProgramiv(programObj, GL_INFO_LOG_LENGTH, &infologLength);
+
+			if (infologLength > 0)
+			{
+				GLint charsWritten = 0;
+
+				GLchar* infoLog = (GLchar*)cm_alloc<ScratchAlloc>(sizeof(GLchar)* infologLength);
+
+				glGetProgramInfoLog(programObj, infologLength, &charsWritten, infoLog);
+
+				stream << "Compile and linker info log: \n";
+				stream << String(infoLog);
+
+				cm_free<ScratchAlloc>(infoLog);
+			}
+		}
+
+		outErrorMsg = stream.str();
+
+		return errorsFound;
+	}
+	
+	GLSLGpuProgram::GLSLGpuProgram(const String& source, const String& entryPoint, GpuProgramType gptype, 
+		GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
+		:GpuProgram(source, entryPoint, gptype, profile, includes, isAdjacencyInfoRequired),
+		mInputOperationType(DOT_TRIANGLE_LIST), mOutputOperationType(DOT_TRIANGLE_LIST), mMaxOutputVertices(3),
+		mProgramID(0), mGLHandle(0)
+    { }
+
+    GLSLGpuProgram::~GLSLGpuProgram()
     {
-		switch(mType)
+    }
+
+	void GLSLGpuProgram::initialize_internal()
+	{
+		if (!isSupported())
+		{
+			mIsCompiled = false;
+			mCompileError = "Specified program is not supported by the current render system.";
+
+			return;
+		}
+
+		mVertexDeclaration = HardwareBufferManager::instance().createVertexDeclaration();
+
+		// only create a shader object if glsl is supported
+		GLenum shaderType = 0x0000;
+		switch (mType)
 		{
 		case GPT_VERTEX_PROGRAM:
+			shaderType = GL_VERTEX_SHADER;
 			mProgramID = ++mVertexShaderCount;
 			break;
 		case GPT_FRAGMENT_PROGRAM:
+			shaderType = GL_FRAGMENT_SHADER;
 			mProgramID = ++mFragmentShaderCount;
 			break;
 		case GPT_GEOMETRY_PROGRAM:
+			shaderType = GL_GEOMETRY_SHADER;
 			mProgramID = ++mGeometryShaderCount;
 			break;
-		case GPT_DOMAIN_PROGRAM:
+		case GPT_HULL_PROGRAM:
+			shaderType = GL_TESS_CONTROL_SHADER;
 			mProgramID = ++mDomainShaderCount;
 			break;
-		case GPT_HULL_PROGRAM:
+		case GPT_DOMAIN_PROGRAM:
+			shaderType = GL_TESS_EVALUATION_SHADER;
 			mProgramID = ++mHullShaderCount;
 			break;
-		default:
-			CM_EXCEPT(InternalErrorException, "Invalid gpu program type: " + toString(mType));
 		}
-    }
-    //-----------------------------------------------------------------------
-    GLSLGpuProgram::~GLSLGpuProgram()
-    {
-    }
 
-	bool GLSLGpuProgram::isSupported() const
+		// Preprocess the GLSL shader in order to get a clean source
+		CPreprocessor cpp;
+
+		// Pass all user-defined macros to preprocessor
+		if (!mPreprocessorDefines.empty())
+		{
+			String::size_type pos = 0;
+			while (pos != String::npos)
+			{
+				// Find delims
+				String::size_type endPos = mPreprocessorDefines.find_first_of(";,=", pos);
+				if (endPos != String::npos)
+				{
+					String::size_type macro_name_start = pos;
+					size_t macro_name_len = endPos - pos;
+					pos = endPos;
+
+					// Check definition part
+					if (mPreprocessorDefines[pos] == '=')
+					{
+						// set up a definition, skip delim
+						++pos;
+						String::size_type macro_val_start = pos;
+						size_t macro_val_len;
+
+						endPos = mPreprocessorDefines.find_first_of(";,", pos);
+						if (endPos == String::npos)
+						{
+							macro_val_len = mPreprocessorDefines.size() - pos;
+							pos = endPos;
+						}
+						else
+						{
+							macro_val_len = endPos - pos;
+							pos = endPos + 1;
+						}
+						cpp.Define(
+							mPreprocessorDefines.c_str() + macro_name_start, macro_name_len,
+							mPreprocessorDefines.c_str() + macro_val_start, macro_val_len);
+					}
+					else
+					{
+						// No definition part, define as "1"
+						++pos;
+						cpp.Define(
+							mPreprocessorDefines.c_str() + macro_name_start, macro_name_len, 1);
+					}
+				}
+				else
+					pos = endPos;
+			}
+		}
+
+		size_t out_size = 0;
+		const char *src = mSource.c_str();
+		size_t src_len = mSource.size();
+		char *out = cpp.Parse(src, src_len, out_size);
+		if (!out || !out_size)
+		{
+			// Failed to preprocess, break out
+			CM_EXCEPT(RenderingAPIException, "Failed to preprocess shader.");
+		}
+
+		mSource = String(out, out_size);
+		if (out < src || out > src + src_len)
+			free(out);
+
+		// Add preprocessor extras and main source
+		if (!mSource.empty())
+		{
+			const char *source = mSource.c_str();
+			mGLHandle = glCreateShaderProgramv(shaderType, 1, &source);
+			
+			mCompileError = "";
+			mIsCompiled = !checkForGLSLError(mGLHandle, mCompileError);
+		}
+
+		if (mIsCompiled)
+		{
+			GLSLParamParser paramParser;
+			paramParser.buildUniformDescriptions(mGLHandle, mParametersDesc);
+			paramParser.buildVertexDeclaration(mGLHandle, *mVertexDeclaration);
+		}
+
+		GpuProgram::initialize_internal();
+	}
+
+	void GLSLGpuProgram::destroy_internal()
 	{
-		if (!isRequiredCapabilitiesSupported())
-			return false;
+		if (mIsCompiled && mGLHandle != 0)
+		{
+			glDeleteProgram(mGLHandle);
+			mGLHandle = 0;
+		}
+
+		GpuProgram::destroy_internal();
+	}
 
-		RenderSystem* rs = BansheeEngine::RenderSystem::instancePtr();
-		return rs->getCapabilities()->isShaderProfileSupported("glsl");
+	const String& GLSLGpuProgram::getLanguage() const
+	{
+		static const String language = "glsl";
+
+		return language;
+	}
+
+	/************************************************************************/
+	/* 								SERIALIZATION                      		*/
+	/************************************************************************/
+	RTTITypeBase* GLSLGpuProgram::getRTTIStatic()
+	{
+		return GLSLGpuProgramRTTI::instance();
+	}
+
+	RTTITypeBase* GLSLGpuProgram::getRTTI() const
+	{
+		return GLSLGpuProgram::getRTTIStatic();
 	}
 }
 

+ 0 - 219
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgram.cpp

@@ -1,219 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmGpuProgram.h"
-#include "CmRenderSystem.h"
-#include "CmRenderSystemCapabilities.h"
-#include "CmGpuProgramManager.h"
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmException.h"
-#include "CmVertexData.h"
-#include "CmIndexData.h"
-#include "CmDebug.h"
-#include "CmGLSLProgram.h"
-#include "CmGLSLGpuProgram.h"
-#include "CmGLSLExtSupport.h"
-#include "CmGLSLPreprocessor.h"
-#include "CmGLSLParamParser.h"
-#include "CmHardwareBufferManager.h"
-
-#include "CmGLSLProgramRTTI.h"
-
-namespace BansheeEngine 
-{
-	//-----------------------------------------------------------------------
-	GLSLProgram::GLSLProgram(const String& source, const String& entryPoint,
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool isAdjacencyInfoRequired)
-		: HighLevelGpuProgram(source, entryPoint, gptype, profile, includes, isAdjacencyInfoRequired),
-		mInputOperationType(DOT_TRIANGLE_LIST),
-		mOutputOperationType(DOT_TRIANGLE_LIST), mMaxOutputVertices(3)
-	{
-
-	}
-	//---------------------------------------------------------------------------
-	GLSLProgram::~GLSLProgram()
-	{
-
-	}
-    //-----------------------------------------------------------------------
-	void GLSLProgram::initialize_internal()
-	{
-		mVertexDeclaration = HardwareBufferManager::instance().createVertexDeclaration();
-
-		// only create a shader object if glsl is supported
-		GLenum shaderType = 0x0000;
-		if (isSupported())
-		{
-			checkForGLSLError( "GLSLProgram::loadFromSource", "GL Errors before creating shader object", 0, GLSLOT_SHADER);
-
-			switch (mType)
-			{
-			case GPT_VERTEX_PROGRAM:
-				shaderType = GL_VERTEX_SHADER;
-				break;
-			case GPT_FRAGMENT_PROGRAM:
-				shaderType = GL_FRAGMENT_SHADER;
-				break;
-			case GPT_GEOMETRY_PROGRAM:
-				shaderType = GL_GEOMETRY_SHADER;
-				break;
-			case GPT_HULL_PROGRAM:
-				shaderType = GL_TESS_CONTROL_SHADER;
-				break;
-			case GPT_DOMAIN_PROGRAM:
-				shaderType = GL_TESS_EVALUATION_SHADER;
-				break;
-			}
-		}
-
-		// Preprocess the GLSL shader in order to get a clean source
-		CPreprocessor cpp;
-
-		// Pass all user-defined macros to preprocessor
-		if (!mPreprocessorDefines.empty ())
-		{
-			String::size_type pos = 0;
-			while (pos != String::npos)
-			{
-				// Find delims
-				String::size_type endPos = mPreprocessorDefines.find_first_of(";,=", pos);
-				if (endPos != String::npos)
-				{
-					String::size_type macro_name_start = pos;
-					size_t macro_name_len = endPos - pos;
-					pos = endPos;
-
-					// Check definition part
-					if (mPreprocessorDefines[pos] == '=')
-					{
-						// set up a definition, skip delim
-						++pos;
-						String::size_type macro_val_start = pos;
-						size_t macro_val_len;
-
-						endPos = mPreprocessorDefines.find_first_of(";,", pos);
-						if (endPos == String::npos)
-						{
-							macro_val_len = mPreprocessorDefines.size () - pos;
-							pos = endPos;
-						}
-						else
-						{
-							macro_val_len = endPos - pos;
-							pos = endPos+1;
-						}
-						cpp.Define (
-							mPreprocessorDefines.c_str () + macro_name_start, macro_name_len,
-							mPreprocessorDefines.c_str () + macro_val_start, macro_val_len);
-					}
-					else
-					{
-						// No definition part, define as "1"
-						++pos;
-						cpp.Define (
-							mPreprocessorDefines.c_str () + macro_name_start, macro_name_len, 1);
-					}
-				}
-				else
-					pos = endPos;
-			}
-		}
-
-		size_t out_size = 0;
-		const char *src = mSource.c_str ();
-		size_t src_len = mSource.size ();
-		char *out = cpp.Parse (src, src_len, out_size);
-		if (!out || !out_size)
-		{
-			// Failed to preprocess, break out
-			CM_EXCEPT(RenderingAPIException, "Failed to preprocess shader ");
-		}
-
-		mSource = String (out, out_size);
-		if (out < src || out > src + src_len)
-			free (out);
-
-		// Add preprocessor extras and main source
-		if (!mSource.empty())
-		{
-			const char *source = mSource.c_str();
-			mGLHandle = glCreateShaderProgramv(shaderType, 1, &source);
-			// check for load errors
-			checkForGLSLError( "GLSLProgram::loadFromSource", "Cannot load GLSL high-level shader source : ", mGLHandle, GLSLOT_PROGRAM, true);
-		}
-
-		mAssemblerProgram = GpuProgramManager::instance().createProgram(mSource, mEntryPoint, mType, mProfile);
-		
-		std::shared_ptr<GLSLGpuProgram> glslGpuProgram = std::static_pointer_cast<GLSLGpuProgram>(mAssemblerProgram);
-		glslGpuProgram->setGLSLProgram(this);
-
-		GLSLParamParser paramParser;
-		paramParser.buildUniformDescriptions(mGLHandle, mParametersDesc);
-		paramParser.buildVertexDeclaration(mGLHandle, *mVertexDeclaration);
-
-		HighLevelGpuProgram::initialize_internal();
-	}
-	//---------------------------------------------------------------------------
-	void GLSLProgram::destroy_internal()
-	{   
-		mAssemblerProgram = nullptr;
-
-		if (isSupported())
-			glDeleteProgram(mGLHandle);
-
-		HighLevelGpuProgram::destroy_internal();
-	}
-    //-----------------------------------------------------------------------
-    const String& GLSLProgram::getLanguage(void) const
-    {
-        static const String language = "glsl";
-
-        return language;
-    }
-
-	bool GLSLProgram::isSupported() const
-	{
-		if (!isRequiredCapabilitiesSupported())
-			return false;
-
-		RenderSystem* rs = BansheeEngine::RenderSystem::instancePtr();
-		return rs->getCapabilities()->isShaderProfileSupported("glsl");
-	}
-
-	/************************************************************************/
-	/* 								SERIALIZATION                      		*/
-	/************************************************************************/
-	RTTITypeBase* GLSLProgram::getRTTIStatic()
-	{
-		return GLSLProgramRTTI::instance();
-	}
-
-	RTTITypeBase* GLSLProgram::getRTTI() const
-	{
-		return GLSLProgram::getRTTIStatic();
-	}
-}

+ 16 - 44
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramFactory.cpp

@@ -1,55 +1,27 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
 #include "CmGLSLProgramFactory.h"
-#include "CmGLSLProgram.h"
+#include "CmGLSLGpuProgram.h"
+
+namespace BansheeEngine 
+{
+    const String GLSLProgramFactory::LANGUAGE_NAME = "glsl";
 
-namespace BansheeEngine {
-    //-----------------------------------------------------------------------
-    String GLSLProgramFactory::sLanguageName = "glsl";
-    //-----------------------------------------------------------------------
-    const String& GLSLProgramFactory::getLanguage(void) const
+    const String& GLSLProgramFactory::getLanguage() const
     {
-        return sLanguageName;
+        return LANGUAGE_NAME;
     }
-    //-----------------------------------------------------------------------
-    HighLevelGpuProgramPtr GLSLProgramFactory::create(const String& source, const String& entryPoint, 
-		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes)
+
+    GpuProgramPtr GLSLProgramFactory::create(const String& source, const String& entryPoint, 
+		GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requireAdjacency)
     {
-		GLSLProgram* prog = new (cm_alloc<GLSLProgram, PoolAlloc>()) GLSLProgram(source, entryPoint, gptype, profile, includes);
+		GLSLGpuProgram* prog = new (cm_alloc<GLSLGpuProgram, PoolAlloc>()) GLSLGpuProgram(source, entryPoint, gptype, profile, includes, requireAdjacency);
 
-		return cm_core_ptr<GLSLProgram, PoolAlloc>(prog);
+		return cm_core_ptr<GLSLGpuProgram, PoolAlloc>(prog);
     }
-	//-----------------------------------------------------------------------
-	HighLevelGpuProgramPtr GLSLProgramFactory::create()
+
+	GpuProgramPtr GLSLProgramFactory::create()
 	{
-		GLSLProgram* prog = new (cm_alloc<GLSLProgram, PoolAlloc>()) GLSLProgram("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr);
+		GLSLGpuProgram* prog = new (cm_alloc<GLSLGpuProgram, PoolAlloc>()) GLSLGpuProgram("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr, false);
 
-		return cm_core_ptr<GLSLProgram, PoolAlloc>(prog);
+		return cm_core_ptr<GLSLGpuProgram, PoolAlloc>(prog);
 	}
 }

+ 5 - 6
CamelotGLRenderer/Source/GLSL/src/CmGLSLProgramPipelineManager.cpp

@@ -1,6 +1,5 @@
 #include "CmGLSLProgramPipelineManager.h"
 #include "CmGLSLGpuProgram.h"
-#include "CmGLSLProgram.h"
 
 namespace BansheeEngine
 {
@@ -51,27 +50,27 @@ namespace BansheeEngine
 
 			if(vertexProgram != nullptr)
 			{
-				glUseProgramStages(newPipeline.glHandle, GL_VERTEX_SHADER_BIT, vertexProgram->getGLSLProgram()->getGLHandle());
+				glUseProgramStages(newPipeline.glHandle, GL_VERTEX_SHADER_BIT, vertexProgram->getGLHandle());
 			}
 
 			if(fragmentProgram != nullptr)
 			{
-				glUseProgramStages(newPipeline.glHandle, GL_FRAGMENT_SHADER_BIT, fragmentProgram->getGLSLProgram()->getGLHandle());
+				glUseProgramStages(newPipeline.glHandle, GL_FRAGMENT_SHADER_BIT, fragmentProgram->getGLHandle());
 			}
 
 			if(geometryProgram != nullptr)
 			{
-				glUseProgramStages(newPipeline.glHandle, GL_GEOMETRY_SHADER_BIT, geometryProgram->getGLSLProgram()->getGLHandle());
+				glUseProgramStages(newPipeline.glHandle, GL_GEOMETRY_SHADER_BIT, geometryProgram->getGLHandle());
 			}
 
 			if(hullProgram != nullptr)
 			{
-				glUseProgramStages(newPipeline.glHandle, GL_TESS_CONTROL_SHADER_BIT, hullProgram->getGLSLProgram()->getGLHandle());
+				glUseProgramStages(newPipeline.glHandle, GL_TESS_CONTROL_SHADER_BIT, hullProgram->getGLHandle());
 			}
 
 			if(domainProgram != nullptr)
 			{
-				glUseProgramStages(newPipeline.glHandle, GL_TESS_EVALUATION_SHADER_BIT, domainProgram->getGLSLProgram()->getGLHandle());
+				glUseProgramStages(newPipeline.glHandle, GL_TESS_EVALUATION_SHADER_BIT, domainProgram->getGLHandle());
 			}
 
 			mPipelines[key] = newPipeline;