Explorar o código

More documentation

BearishSun %!s(int64=11) %!d(string=hai) anos
pai
achega
4ac20c7df5

+ 0 - 2
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\CmGpuProgramParams.h" />
     <ClInclude Include="Include\CmGpuProgramRTTI.h" />
     <ClInclude Include="Include\CmHardwareBuffer.h" />
     <ClInclude Include="Include\CmHardwareBufferManager.h" />
@@ -451,7 +450,6 @@
     <ClCompile Include="Source\CmGpuProgram.cpp" />
     <ClCompile Include="Source\CmGpuProgramImporter.cpp" />
     <ClCompile Include="Source\CmGpuProgramImportOptions.cpp" />
-    <ClCompile Include="Source\CmGpuProgramParams.cpp" />
     <ClCompile Include="Source\CmGpuResource.cpp" />
     <ClCompile Include="Source\CmGpuResourceData.cpp" />
     <ClCompile Include="Source\CmHardwareBufferManager.cpp" />

+ 0 - 6
CamelotCore/CamelotCore.vcxproj.filters

@@ -135,9 +135,6 @@
     <ClInclude Include="Include\CmHardwareBufferManager.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmGpuProgramParams.h">
-      <Filter>Header Files\RenderSystem</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmGpuProgram.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
@@ -545,9 +542,6 @@
     <ClCompile Include="Source\CmGpuProgram.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>

+ 3 - 4
CamelotCore/Include/CmGpuProgram.h

@@ -2,7 +2,6 @@
 
 #include "CmPrerequisites.h"
 #include "CmDrawOps.h"
-#include "CmGpuProgramParams.h"
 #include "CmResource.h"
 #include "CmGpuParamDesc.h"
 
@@ -121,7 +120,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Only relevant for geometry programs.
 		 */
-		virtual bool isAdjacencyInfoRequired(void) const { return mNeedsAdjacencyInfo; }
+		virtual bool isAdjacencyInfoRequired() const { return mNeedsAdjacencyInfo; }
 
 		/**
 		 * @brief	Creates a new parameters object compatible with this program definition. You
@@ -173,12 +172,12 @@ namespace BansheeEngine
 		/**
 		 * @brief	Returns whether required capabilities for this program is supported.
 		 */
-        bool isRequiredCapabilitiesSupported(void) const;
+        bool isRequiredCapabilitiesSupported() const;
 
 		/**
 		 * @copydoc Resource::calculateSize
 		 */
-		size_t calculateSize(void) const { return 0; } // TODO 
+		size_t calculateSize() const { return 0; } // TODO 
 
 	protected:
 		GpuProgramType mType;

+ 64 - 30
CamelotCore/Include/CmGpuProgramManager.h

@@ -7,61 +7,95 @@
 
 namespace BansheeEngine 
 {
+	/**
+	 * @brief	Factory responsible for creating GPU programs of a certain type.
+	 */
 	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;
+
+		/**
+		 * @brief	Returns GPU program language this factory is capable creating GPU programs from.
+		 */
+		virtual const String& getLanguage() const = 0;
+
+		virtual GpuProgramPtr create(const String& source, const String& entryPoint, GpuProgramType gptype, 
+			GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, bool requiresAdjacencyInformation) = 0;
+
+		/**
+		 * @copydoc	GpuProgramManager::createEmpty
+		 */
 		virtual GpuProgramPtr create(GpuProgramType type) = 0;
 	};
 
+	/**
+	 * @brief	Manager responsible for creating GPU programs. It will automatically
+	 *			try to find the approriate handler for a specific GPU program language
+	 *			and create the program if possible.
+	 *
+	 * @note	Sim thread only.
+	 */
 	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();
 		~GpuProgramManager();
-		/** Add a new factory object for high-level programs of a given language. */
+
+		/**
+		 * @brief	Registers a new factory that is able to create GPU programs for a certain language.
+		 *			If any other factory for the same language exists, it will overwrite it.
+		 */
 		void addFactory(GpuProgramFactory* factory);
-		/** Remove a factory object for high-level programs of a given language. */
+
+		/**
+		 * @brief	Unregisters a GPU program factory, essentially making it not possible to create GPU programs
+		 *			using the language the factory supported.
+		 */
 		void removeFactory(GpuProgramFactory* factory);
 
-		/** Returns whether a given high-level language is supported. */
+		/**
+		 * @brief	Query if a GPU program language is supported. (.e.g. "hlsl", "glsl").
+		 */
 		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
-		*/
+		/**
+		 * @brief	Creates a new GPU program using the provided source code. If compilation fails or program is not supported
+		 *			"isCompiled" method on the returned program will 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.
+		 */
 		GpuProgramPtr create(const String& source, const String& entryPoint, const String& language, 
 			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
-			bool requiresAdjacencyInformation = false);
+			bool requiresAdjacency = false);
 
 		/**
-		 * @brief	Creates a completely empty and uninitialized HighLevelGpuProgram.
-		 * 			Should only be used for VERY specific purposes, like deserialization,
+		 * @brief	Creates a completely empty and uninitialized GpuProgram.
+		 * 			Should only be used for specific purposes, like deserialization,
 		 * 			as it requires additional manual initialization that is not required normally.
 		 */
 		GpuProgramPtr createEmpty(const String& language, GpuProgramType type);
+
+	protected:
+		/**
+		 * @brief	Attempts to find a factory for the specified language. Returns null if it cannot find one.
+		 */
+		GpuProgramFactory* getFactory(const String& language);
+
+	protected:
+		typedef Map<String, GpuProgramFactory*> FactoryMap;
+
+		FactoryMap mFactories;
+		GpuProgramFactory* mNullFactory; /**< Factory for dealing with GPU programs that can't be created. */
 	};
 }

+ 0 - 983
CamelotCore/Include/CmGpuProgramParams.h

@@ -1,983 +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 __GpuProgramParams_H_
-#define __GpuProgramParams_H_
-
-// Precompiler options
-#include "CmPrerequisites.h"
-#include "CmDrawOps.h"
-#include "CmSamplerState.h"
-
-namespace BansheeEngine {
-
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup Materials
-	*  @{
-	*/
-	/** Enumeration of the types of constant we may encounter in programs. 
-	@note Low-level programs, by definition, will always use either
-	float4 or int4 constant types since that is the fundamental underlying
-	type in assembler.
-	*/
-	enum GpuConstantType
-	{
-		GCT_FLOAT1 = 1,
-		GCT_FLOAT2 = 2,
-		GCT_FLOAT3 = 3,
-		GCT_FLOAT4 = 4,
-		GCT_SAMPLER1D = 5,
-		GCT_SAMPLER2D = 6,
-		GCT_SAMPLER3D = 7,
-		GCT_SAMPLERCUBE = 8,
-		GCT_SAMPLER1DSHADOW = 9,
-		GCT_SAMPLER2DSHADOW = 10,
-		GCT_MATRIX_2X2 = 11,
-		GCT_MATRIX_2X3 = 12,
-		GCT_MATRIX_2X4 = 13,
-		GCT_MATRIX_3X2 = 14,
-		GCT_MATRIX_3X3 = 15,
-		GCT_MATRIX_3X4 = 16,
-		GCT_MATRIX_4X2 = 17,
-		GCT_MATRIX_4X3 = 18,
-		GCT_MATRIX_4X4 = 19,
-		GCT_INT1 = 20,
-		GCT_INT2 = 21,
-		GCT_INT3 = 22,
-		GCT_INT4 = 23,
-		GCT_UNKNOWN = 99
-	};
-
-	/** The variability of a GPU parameter, as derived from auto-params targetting it.
-	These values must be powers of two since they are used in masks.
-	*/
-	enum GpuParamVariability
-	{
-		/// No variation except by manual setting - the default
-		GPV_GLOBAL = 1, 
-		/// Varies per object (based on an auto param usually), but not per light setup
-		GPV_PER_OBJECT = 2, 
-		/// Varies with light setup
-		GPV_LIGHTS = 4, 
-
-		/// Full mask (16-bit)
-		GPV_ALL = 0xFFFF
-
-	};
-
-	/** Information about predefined program constants. 
-	@note Only available for high-level programs but is referenced generically
-	by GpuProgramParameters.
-	*/
-	struct CM_EXPORT GpuConstantDefinition
-	{
-		/// Data type
-		GpuConstantType constType;
-		/// Physical start index in buffer (either float or int buffer)
-		UINT32 physicalIndex;
-		/// Logical index - used to communicate this constant to the rendersystem
-		UINT32 logicalIndex;
-		/** Number of raw buffer slots per element 
-		(some programs pack each array element to float4, some do not) */
-		UINT32 elementSize;
-		/// Length of array
-		UINT32 arraySize;
-		/// How this parameter varies (bitwise combination of GpuProgramVariability)
-		mutable UINT16 variability;
-
-		bool isFloat() const
-		{
-			return isFloat(constType);
-		}
-
-		static bool isFloat(GpuConstantType c)
-		{
-			switch(c)
-			{
-			case GCT_INT1:
-			case GCT_INT2:
-			case GCT_INT3:
-			case GCT_INT4:
-			case GCT_SAMPLER1D:
-			case GCT_SAMPLER2D:
-			case GCT_SAMPLER3D:
-			case GCT_SAMPLERCUBE:
-			case GCT_SAMPLER1DSHADOW:
-			case GCT_SAMPLER2DSHADOW:
-				return false;
-			default:
-				return true;
-			};
-
-		}
-
-		bool isSampler() const
-		{
-			return isSampler(constType);
-		}
-
-		static bool isSampler(GpuConstantType c)
-		{
-			switch(c)
-			{
-			case GCT_SAMPLER1D:
-			case GCT_SAMPLER2D:
-			case GCT_SAMPLER3D:
-			case GCT_SAMPLERCUBE:
-			case GCT_SAMPLER1DSHADOW:
-			case GCT_SAMPLER2DSHADOW:
-				return true;
-			default:
-				return false;
-			};
-
-		}
-
-
-		/** Get the element size of a given type, including whether to pad the 
-			elements into multiples of 4 (e.g. SM1 and D3D does, GLSL doesn't)
-		*/
-		static UINT32 getElementSize(GpuConstantType ctype, bool padToMultiplesOf4)
-		{
-			if (padToMultiplesOf4)
-			{
-				switch(ctype)
-				{
-				case GCT_SAMPLER1D:
-				case GCT_SAMPLER2D:
-				case GCT_SAMPLER3D:
-				case GCT_SAMPLERCUBE:
-				case GCT_SAMPLER1DSHADOW:
-				case GCT_SAMPLER2DSHADOW:
-					return 1; // Samplers aren't like other variables so they won't be padded
-				case GCT_FLOAT1:
-				case GCT_INT1:
-				case GCT_FLOAT2:
-				case GCT_INT2:
-				case GCT_FLOAT3:
-				case GCT_INT3:
-				case GCT_FLOAT4:
-				case GCT_INT4:
-				case GCT_MATRIX_2X2:
-					return 4;
-				case GCT_MATRIX_2X3:
-				case GCT_MATRIX_2X4:
-					return 8; // 2 float4s
-				case GCT_MATRIX_3X2:
-				case GCT_MATRIX_3X3:
-				case GCT_MATRIX_3X4:
-					return 12; // 3 float4s
-				case GCT_MATRIX_4X2:
-				case GCT_MATRIX_4X3:
-				case GCT_MATRIX_4X4:
-					return 16; // 4 float4s
-				default:
-					return 4;
-				};
-			}
-			else
-			{
-				switch(ctype)
-				{
-				case GCT_FLOAT1:
-				case GCT_INT1:
-				case GCT_SAMPLER1D:
-				case GCT_SAMPLER2D:
-				case GCT_SAMPLER3D:
-				case GCT_SAMPLERCUBE:
-				case GCT_SAMPLER1DSHADOW:
-				case GCT_SAMPLER2DSHADOW:
-					return 1;
-				case GCT_FLOAT2:
-				case GCT_INT2:
-					return 2;
-				case GCT_FLOAT3:
-				case GCT_INT3:
-					return 3;
-				case GCT_FLOAT4:
-				case GCT_INT4:
-					return 4;
-				case GCT_MATRIX_2X2:
-					return 4;
-				case GCT_MATRIX_2X3:
-				case GCT_MATRIX_3X2:
-					return 6;
-				case GCT_MATRIX_2X4:
-				case GCT_MATRIX_4X2:
-					return 8; 
-				case GCT_MATRIX_3X3:
-					return 9;
-				case GCT_MATRIX_3X4:
-				case GCT_MATRIX_4X3:
-					return 12; 
-				case GCT_MATRIX_4X4:
-					return 16; 
-				default:
-					return 4;
-				};
-
-			}
-		}
-
-		GpuConstantDefinition()
-			: constType(GCT_UNKNOWN)
-			, physicalIndex((std::numeric_limits<UINT32>::max)())
-			, elementSize(0)
-			, arraySize(1)
-			, variability(GPV_GLOBAL) {}
-	};
-	typedef Map<String, GpuConstantDefinition> GpuConstantDefinitionMap;
-	typedef GpuConstantDefinitionMap::const_iterator GpuConstantDefinitionIterator;
-
-	/// Struct collecting together the information for named constants.
-	struct CM_EXPORT GpuNamedConstants
-	{
-		/// Total size of the float buffer required
-		UINT32 floatBufferSize;
-		/// Total size of the int buffer required
-		UINT32 intBufferSize;
-		/// Total number of samplers referenced
-		UINT32 samplerCount;
-		/// Total number of textures references
-		UINT32 textureCount;
-		/// Map of parameter names to GpuConstantDefinition
-		GpuConstantDefinitionMap map;
-
-		GpuNamedConstants() : floatBufferSize(0), intBufferSize(0), 
-			samplerCount(0), textureCount(0) {}
-
-		/** Generate additional constant entries for arrays based on a base definition.
-		@remarks
-		Array uniforms will be added just with their base name with no array
-		suffix. This method will add named entries for array suffixes too
-		so individual array entries can be addressed. Note that we only 
-		individually index array elements if the array size is up to 16
-		entries in size. Anything larger than that only gets a [0] entry
-		as well as the main entry, to save cluttering up the name map. After
-		all, you can address the larger arrays in a bulk fashion much more
-		easily anyway. 
-		*/
-		void generateConstantDefinitionArrayEntries(const String& paramName, 
-			const GpuConstantDefinition& baseDef);
-
-		/// Indicates whether all array entries will be generated and added to the definitions map
-		static bool getGenerateAllConstantDefinitionArrayEntries();
-
-		/** Sets whether all array entries will be generated and added to the definitions map.
-		@remarks
-		Usually, array entries can only be individually indexed if they're up to 16 entries long,
-		to save memory - arrays larger than that can be set but only via the bulk setting
-		methods. This option allows you to choose to individually index every array entry. 
-		*/
-		static void setGenerateAllConstantDefinitionArrayEntries(bool generateAll);
-
-	protected:
-		/** Indicates whether all array entries will be generated and added to the definitions map
-		@remarks
-		Normally, the number of array entries added to the definitions map is capped at 16
-		to save memory. Setting this value to <code>true</code> allows all of the entries
-		to be generated and added to the map.
-		*/
-		static bool msGenerateAllConstantDefinitionArrayEntries;
-	};
-	typedef std::shared_ptr<GpuNamedConstants> GpuNamedConstantsPtr;
-
-	/** Structure recording the use of a physical buffer by a logical parameter
-	index. Only used for low-level programs.
-	*/
-	struct CM_EXPORT GpuLogicalIndexUse
-	{
-		/// Physical buffer index
-		UINT32 physicalIndex;
-		/// Current physical size allocation
-		UINT32 currentSize;
-		/// How the contents of this slot vary
-		mutable UINT16 variability;
-
-		GpuLogicalIndexUse() 
-			: physicalIndex(99999), currentSize(0), variability(GPV_GLOBAL) {}
-		GpuLogicalIndexUse(UINT32 bufIdx, UINT32 curSz, UINT32 v) 
-			: physicalIndex(bufIdx), currentSize(curSz), variability(v) {}
-	};
-	typedef Map<UINT32, GpuLogicalIndexUse> GpuLogicalIndexUseMap;
-	/// Container struct to allow params to safely & update shared list of logical buffer assignments
-	struct CM_EXPORT GpuLogicalBufferStruct
-	{
-		/// Map from logical index to physical buffer location
-		GpuLogicalIndexUseMap map;
-		/// Shortcut to know the buffer size needs
-		UINT32 bufferSize;
-		GpuLogicalBufferStruct() : bufferSize(0) {}
-	};
-	typedef std::shared_ptr<GpuLogicalBufferStruct> GpuLogicalBufferStructPtr;
-
-	/** Definition of container that holds the current float constants.
-	@note Not necessarily in direct index order to constant indexes, logical
-	to physical index map is derived from GpuProgram
-	*/
-	typedef Vector<float> FloatConstantList;
-	/** Definition of container that holds the current float constants.
-	@note Not necessarily in direct index order to constant indexes, logical
-	to physical index map is derived from GpuProgram
-	*/
-	typedef Vector<int> IntConstantList;
-
-	/** Collects together the program parameters used for a GpuProgram.
-	@remarks
-	Gpu program state includes constant parameters used by the program, and
-	bindings to render system state which is propagated into the constants 
-	by the engine automatically if requested.
-	@par
-	GpuProgramParameters objects should be created through the GpuProgram and
-	may be shared between multiple Pass instances. For this reason they
-	are managed using a shared pointer, which will ensure they are automatically
-	deleted when no Pass is using them anymore. 
-	@par
-	High-level programs use named parameters (uniforms), low-level programs 
-	use indexed constants. This class supports both, but you can tell whether 
-	named constants are supported by calling hasNamedParameters(). There are
-	references in the documentation below to 'logical' and 'physical' indexes;
-	logical indexes are the indexes used by low-level programs and represent 
-	indexes into an array of float4's, some of which may be settable, some of
-	which may be predefined constants in the program. We only store those
-	constants which have actually been set, therefore our buffer could have 
-	gaps if we used the logical indexes in our own buffers. So instead we map
-	these logical indexes to physical indexes in our buffer. When using 
-	high-level programs, logical indexes don't necessarily exist, although they
-	might if the high-level program has a direct, exposed mapping from parameter
-	names to logical indexes. In addition, high-level languages may or may not pack
-	arrays of elements that are smaller than float4 (e.g. float2/vec2) contiguously.
-	This kind of information is held in the ConstantDefinition structure which 
-	is only populated for high-level programs. You don't have to worry about
-	any of this unless you intend to read parameters back from this structure
-	rather than just setting them.
-	*/
-	class CM_EXPORT GpuProgramParameters
-	{
-	public:
-		/** Defines the type of the extra data item used by the auto constant.
-
-		*/
-		enum ACDataType {
-			/// no data is required
-			ACDT_NONE,
-			/// the auto constant requires data of type int
-			ACDT_INT,
-			/// the auto constant requires data of type real
-			ACDT_REAL
-		};
-
-		/** Defines the base element type of the auto constant
-		*/
-		enum ElementType {
-			ET_INT,
-			ET_REAL
-		};
-
-	protected:
-		/// Packed list of floating-point constants (physical indexing)
-		FloatConstantList mFloatConstants;
-		/// Packed list of integer constants (physical indexing)
-		IntConstantList mIntConstants;
-		/// List of all texture parameters
-		Vector<HTexture> mTextures;
-		// List of all sampler states
-		Vector<SamplerStatePtr> mSamplerStates;
-		/** Logical index to physical index map - for low-level programs
-		or high-level programs which pass params this way. */
-		GpuLogicalBufferStructPtr mFloatLogicalToPhysical;
-		/** Logical index to physical index map - for low-level programs
-		or high-level programs which pass params this way. */
-		GpuLogicalBufferStructPtr mIntLogicalToPhysical;
-		/** Logical index to physical index map - for low-level programs
-		or high-level programs which pass params this way. */
-		GpuLogicalBufferStructPtr mTextureLogicalToPhysical;
-		/** Logical index to physical index map - for low-level programs
-		or high-level programs which pass params this way. */
-		GpuLogicalBufferStructPtr mSamplerLogicalToPhysical;
-		/// Mapping from parameter names to def - high-level programs are expected to populate this
-		GpuNamedConstantsPtr mNamedConstants;
-		/// The combined variability masks of all parameters
-		UINT16 mCombinedVariability;
-		/// Do we need to transpose matrices?
-		bool mTransposeMatrices;
-		/// flag to indicate if names not found will be ignored
-		bool mIgnoreMissingParams;
-
-		/** Gets the low-level structure for a logical index. 
-		*/
-		GpuLogicalIndexUse* _getFloatConstantLogicalIndexUse(UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability);
-		/** Gets the physical buffer index associated with a logical int constant index. 
-		*/
-		GpuLogicalIndexUse* _getIntConstantLogicalIndexUse(UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability);
-
-	public:
-		GpuProgramParameters();
-		~GpuProgramParameters() {}
-
-		/// Copy constructor
-		GpuProgramParameters(const GpuProgramParameters& oth);
-		/// Operator = overload
-		GpuProgramParameters& operator=(const GpuProgramParameters& oth);
-
-		/** Internal method for providing a link to a name->definition map for parameters. */
-		void _setNamedConstants(const GpuNamedConstantsPtr& constantmap);
-
-		/** Internal method for providing a link to a logical index->physical index map for parameters. */
-		void _setLogicalIndexes(const GpuLogicalBufferStructPtr& floatIndexMap, 
-			const GpuLogicalBufferStructPtr& intIndexMap, 
-			const GpuLogicalBufferStructPtr& samplerIndexMap,
-			const GpuLogicalBufferStructPtr& textureIndexMap
-			);
-
-
-		/// Does this parameter set include named parameters?
-		bool hasNamedParameters() const { return mNamedConstants != nullptr; }
-		/** Does this parameter set include logically indexed parameters?
-		@note Not mutually exclusive with hasNamedParameters since some high-level
-		programs still use logical indexes to set the parameters on the 
-		rendersystem.
-		*/
-		bool hasLogicalIndexedParameters() const { return mFloatLogicalToPhysical != nullptr; }
-
-		/** Sets a 4-element floating-point parameter to the program.
-		@param index The logical constant index at which to place the parameter 
-		(each constant is a 4D float)
-		@param vec The value to set
-		*/
-		void setConstant(UINT32 index, const Vector4& vec);
-		/** Sets a single floating-point parameter to the program.
-		@note This is actually equivalent to calling 
-		setConstant(index Vector4(val, 0, 0, 0)) since all constants are 4D.
-		@param index The logical constant index at which to place the parameter (each constant is
-		a 4D float)
-		@param val The value to set
-		*/
-		void setConstant(UINT32 index, float val);
-		/** Sets a 4-element floating-point parameter to the program via Vector3.
-		@param index The logical constant index at which to place the parameter (each constant is
-		a 4D float).
-		Note that since you're passing a Vector3, the last element of the 4-element
-		value will be set to 1 (a homogeneous vector)
-		@param vec The value to set
-		*/
-		void setConstant(UINT32 index, const Vector3& vec);
-		/** Sets a Matrix4 parameter to the program.
-		@param index The logical constant index at which to place the parameter (each constant is
-		a 4D float).
-		NB since a Matrix4 is 16 floats long, this parameter will take up 4 indexes.
-		@param m The value to set
-		*/
-		void setConstant(UINT32 index, const Matrix4& m);
-		/** Sets a list of Matrix4 parameters to the program.
-		@param index The logical constant index at which to start placing the parameter (each constant is
-		a 4D float).
-		NB since a Matrix4 is 16 floats long, so each entry will take up 4 indexes.
-		@param m Pointer to an array of matrices to set
-		@param numEntries Number of Matrix4 entries
-		*/
-		void setConstant(UINT32 index, const Matrix4* m, UINT32 numEntries);
-		/** Sets a multiple value constant floating-point parameter to the program.
-		@param index The logical constant index at which to start placing parameters (each constant is
-		a 4D float)
-		@param val Pointer to the values to write, must contain 4*count floats
-		@param count The number of groups of 4 floats to write
-		*/
-		void setConstant(UINT32 index, const float *val, UINT32 count);
-		/** Sets a multiple value constant floating-point parameter to the program.
-		@param index The logical constant index at which to start placing parameters (each constant is
-		a 4D float)
-		@param val Pointer to the values to write, must contain 4*count floats
-		@param count The number of groups of 4 floats to write
-		*/
-		void setConstant(UINT32 index, const double *val, UINT32 count);
-		/** Sets a ColourValue parameter to the program.
-		@param index The logical constant index at which to place the parameter (each constant is
-		a 4D float)
-		@param colour The value to set
-		*/
-		void setConstant(UINT32 index, const Color& colour);
-
-		/** Sets a multiple value constant integer parameter to the program.
-		@remarks
-		Different types of GPU programs support different types of constant parameters.
-		For example, it's relatively common to find that vertex programs only support
-		floating point constants, and that fragment programs only support integer (fixed point)
-		parameters. This can vary depending on the program version supported by the
-		graphics card being used. You should consult the documentation for the type of
-		low level program you are using, or alternatively use the methods
-		provided on RenderSystemCapabilities to determine the options.
-		@param index The logical constant index at which to place the parameter (each constant is
-		a 4D integer)
-		@param val Pointer to the values to write, must contain 4*count ints
-		@param count The number of groups of 4 ints to write
-		*/
-		void setConstant(UINT32 index, const int *val, UINT32 count);
-
-		/** Write a series of floating point values into the underlying float 
-		constant buffer at the given physical index.
-		@param physicalIndex The buffer position to start writing
-		@param val Pointer to a list of values to write
-		@param count The number of floats to write
-		*/
-		void _writeRawConstants(UINT32 physicalIndex, const float* val, UINT32 count);
-		/** Write a series of floating point values into the underlying float 
-		constant buffer at the given physical index.
-		@param physicalIndex The buffer position to start writing
-		@param val Pointer to a list of values to write
-		@param count The number of floats to write
-		*/
-		void _writeRawConstants(UINT32 physicalIndex, const double* val, UINT32 count);
-		/** Write a series of integer values into the underlying integer
-		constant buffer at the given physical index.
-		@param physicalIndex The buffer position to start writing
-		@param val Pointer to a list of values to write
-		@param count The number of ints to write
-		*/
-		void _writeRawConstants(UINT32 physicalIndex, const int* val, UINT32 count);
-		/** Read a series of floating point values from the underlying float 
-		constant buffer at the given physical index.
-		@param physicalIndex The buffer position to start reading
-		@param count The number of floats to read
-		@param dest Pointer to a buffer to receive the values
-		*/
-		void _readRawConstants(UINT32 physicalIndex, UINT32 count, float* dest);
-		/** Read a series of integer values from the underlying integer 
-		constant buffer at the given physical index.
-		@param physicalIndex The buffer position to start reading
-		@param count The number of ints to read
-		@param dest Pointer to a buffer to receive the values
-		*/
-		void _readRawConstants(UINT32 physicalIndex, UINT32 count, int* dest);
-		/** Read a texture from the underlying texture 
-		array at the given physical index.
-		@param physicalIndex The array position of the texture
-		@param dest Reference of the texture to store
-		*/
-		void _readTexture(UINT32 physicalIndex, HTexture& dest);
-		/** Write a 4-element floating-point parameter to the program directly to 
-		the underlying constants buffer.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param vec The value to set
-		@param count The number of floats to write; if for example
-		the uniform constant 'slot' is smaller than a Vector4
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, const Vector4& vec, 
-			UINT32 count = 4);
-		/** Write a single floating-point parameter to the program.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param val The value to set
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, float val);
-		/** Write a single integer parameter to the program.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param val The value to set
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, int val);
-		/** Write a 3-element floating-point parameter to the program via Vector3.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param vec The value to set
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, const Vector3& vec);
-		/** Write a 2-element floating-point parameter to the program via Vector2.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param vec The value to set
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, const Vector2& vec);
-		/** Write a Matrix4 parameter to the program.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param m The value to set
-		@param elementCount actual element count used with shader
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, const Matrix4& m, UINT32 elementCount);
-		/** Write a list of Matrix4 parameters to the program.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param numEntries Number of Matrix4 entries
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, const Matrix4* m, UINT32 numEntries);
-		/** Write a Matrix3 parameter to the program.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param m The value to set
-		@param elementCount actual element count used with shader
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, const Matrix3& m, UINT32 elementCount);
-		/** Write a ColourValue parameter to the program.
-		@note You can use these methods if you have already derived the physical
-		constant buffer location, for a slight speed improvement over using
-		the named / logical index versions.
-		@param physicalIndex The physical buffer index at which to place the parameter 
-		@param colour The value to set
-		@param count The number of floats to write; if for example
-		the uniform constant 'slot' is smaller than a Vector4
-		*/
-		void _writeRawConstant(UINT32 physicalIndex, const Color& colour, 
-			UINT32 count = 4);
-
-
-		/** Gets an iterator over the named GpuConstantDefinition instances as defined
-		by the program for which these parameters exist.
-		@note
-		Only available if this parameters object has named parameters.
-		*/
-		GpuConstantDefinitionIterator getConstantDefinitionIterator(void) const;
-
-		/** Get a specific GpuConstantDefinition for a named parameter.
-		@note
-		Only available if this parameters object has named parameters.
-		*/
-		const GpuConstantDefinition& getConstantDefinition(const String& name) const;
-
-		/** Get the full list of GpuConstantDefinition instances.
-		@note
-		Only available if this parameters object has named parameters.
-		*/
-		const GpuNamedConstants& getConstantDefinitions() const;
-
-		/** Get the current list of mappings from low-level logical param indexes
-		to physical buffer locations in the float buffer.
-		@note
-		Only applicable to low-level programs.
-		*/
-		const GpuLogicalBufferStructPtr& getFloatLogicalBufferStruct() const { return mFloatLogicalToPhysical; }
-
-		/** Retrieves the logical index relating to a physical index in the float
-		buffer, for programs which support that (low-level programs and 
-		high-level programs which use logical parameter indexes).
-		@returns std::numeric_limits<UINT32>::max() if not found
-		*/
-		UINT32 getFloatLogicalIndexForPhysicalIndex(UINT32 physicalIndex);
-		/** Retrieves the logical index relating to a physical index in the int
-		buffer, for programs which support that (low-level programs and 
-		high-level programs which use logical parameter indexes).
-		@returns std::numeric_limits<UINT32>::max() if not found
-		*/
-		UINT32 getIntLogicalIndexForPhysicalIndex(UINT32 physicalIndex);
-
-		/** Get the current list of mappings from low-level logical param indexes
-		to physical buffer locations in the integer buffer.
-		@note
-		Only applicable to low-level programs.
-		*/
-		const GpuLogicalBufferStructPtr& getIntLogicalBufferStruct() const { return mIntLogicalToPhysical; }
-		/// Get a reference to the list of float constants
-		const FloatConstantList& getFloatConstantList() const { return mFloatConstants; }
-		/// Get a pointer to the 'nth' item in the float buffer
-		float* getFloatPointer(UINT32 pos) { return &mFloatConstants[pos]; }
-		/// Get a pointer to the 'nth' item in the float buffer
-		const float* getFloatPointer(UINT32 pos) const { return &mFloatConstants[pos]; }
-		/// Get a reference to the list of int constants
-		const IntConstantList& getIntConstantList() const { return mIntConstants; }
-		/// Get a pointer to the 'nth' item in the int buffer
-		int* getIntPointer(UINT32 pos) { return &mIntConstants[pos]; }
-		/// Get a pointer to the 'nth' item in the int buffer
-		const int* getIntPointer(UINT32 pos) const { return &mIntConstants[pos]; }
-		const GpuLogicalBufferStructPtr& getTextureLogicalBufferStruct() const { return mTextureLogicalToPhysical; }
-		HTexture getTexture(UINT32 pos) const;
-		const GpuLogicalBufferStructPtr& getSamplerLogicalBufferStruct() const { return mSamplerLogicalToPhysical; }
-		SamplerStatePtr getSamplerState(UINT32 pos) const;
-		/// Get a reference to the list of textures
-		const Vector<HTexture>& getTextureList() const { return mTextures; }
-		UINT32 getNumTextures() const { return (UINT32)mTextures.size(); }
-		const Vector<SamplerStatePtr>& getSamplerStateList() const { return mSamplerStates; }
-		UINT32 getNumSamplerStates() const { return (UINT32)mSamplerStates.size(); }
-
-		/** Tells the program whether to ignore missing parameters or not.
-		*/
-		void setIgnoreMissingParams(bool state) { mIgnoreMissingParams = state; }
-
-		/** Sets a texture parameter to the program.
-		@remarks
-		Different types of GPU programs support different types of constant parameters.
-		For example, it's relatively common to find that vertex programs only support
-		floating point constants, and that fragment programs only support integer (fixed point)
-		parameters. This can vary depending on the program version supported by the
-		graphics card being used. You should consult the documentation for the type of
-		low level program you are using, or alternatively use the methods
-		provided on RenderSystemCapabilities to determine the options.
-		@par
-		Another possible limitation is that some systems only allow constants to be set
-		on certain boundaries, e.g. in sets of 4 values for example. Again, see
-		RenderSystemCapabilities for full details.
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param name The name of the parameter
-		@param val The value to set
-		*/
-		void setNamedConstant(const String& name, HTexture val);
-
-		/** Sets a sampler state to the program. Name of the sampler should be the same
-		as the name of the texture parameter it is being set for.
-		@remarks
-		Different types of GPU programs support different types of constant parameters.
-		For example, it's relatively common to find that vertex programs only support
-		floating point constants, and that fragment programs only support integer (fixed point)
-		parameters. This can vary depending on the program version supported by the
-		graphics card being used. You should consult the documentation for the type of
-		low level program you are using, or alternatively use the methods
-		provided on RenderSystemCapabilities to determine the options.
-		@par
-		Another possible limitation is that some systems only allow constants to be set
-		on certain boundaries, e.g. in sets of 4 values for example. Again, see
-		RenderSystemCapabilities for full details.
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param name The name of the parameter
-		@param val The value to set
-		*/
-		void setNamedConstant(const String& name, SamplerStatePtr val);
-
-		/** Sets a single value constant floating-point parameter to the program.
-		@remarks
-		Different types of GPU programs support different types of constant parameters.
-		For example, it's relatively common to find that vertex programs only support
-		floating point constants, and that fragment programs only support integer (fixed point)
-		parameters. This can vary depending on the program version supported by the
-		graphics card being used. You should consult the documentation for the type of
-		low level program you are using, or alternatively use the methods
-		provided on RenderSystemCapabilities to determine the options.
-		@par
-		Another possible limitation is that some systems only allow constants to be set
-		on certain boundaries, e.g. in sets of 4 values for example. Again, see
-		RenderSystemCapabilities for full details.
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param name The name of the parameter
-		@param val The value to set
-		*/
-		void setNamedConstant(const String& name, float val);
-		/** Sets a single value constant integer parameter to the program.
-		@remarks
-		Different types of GPU programs support different types of constant parameters.
-		For example, it's relatively common to find that vertex programs only support
-		floating point constants, and that fragment programs only support integer (fixed point)
-		parameters. This can vary depending on the program version supported by the
-		graphics card being used. You should consult the documentation for the type of
-		low level program you are using, or alternatively use the methods
-		provided on RenderSystemCapabilities to determine the options.
-		@par
-		Another possible limitation is that some systems only allow constants to be set
-		on certain boundaries, e.g. in sets of 4 values for example. Again, see
-		RenderSystemCapabilities for full details.
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param name The name of the parameter
-		@param val The value to set
-		*/
-		void setNamedConstant(const String& name, int val);
-		/** Sets a Vector4 parameter to the program.
-		@param name The name of the parameter
-		@param vec The value to set
-		*/
-		void setNamedConstant(const String& name, const Vector4& vec);
-		/** Sets a Vector3 parameter to the program.
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param index The index at which to place the parameter
-		NB this index refers to the number of floats, so a Vector3 is 3. Note that many 
-		rendersystems & programs assume that every floating point parameter is passed in
-		as a vector of 4 items, so you are strongly advised to check with 
-		RenderSystemCapabilities before using this version - if in doubt use Vector4
-		or ColourValue instead (both are 4D).
-		@param vec The value to set
-		*/
-		void setNamedConstant(const String& name, const Vector3& vec);
-		/** Sets a Vector2 parameter to the program.
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param vec The value to set
-		*/
-		void setNamedConstant(const String& name, const Vector2& vec);
-		/** Sets a Matrix4 parameter to the program.
-		@param name The name of the parameter
-		@param m The value to set
-		*/
-		void setNamedConstant(const String& name, const Matrix4& m);
-		/** Sets a list of Matrix4 parameters to the program.
-		@param name The name of the parameter; this must be the first index of an array,
-		for examples 'matrices[0]'
-		NB since a Matrix4 is 16 floats long, so each entry will take up 4 indexes.
-		@param m Pointer to an array of matrices to set
-		@param numEntries Number of Matrix4 entries
-		*/
-		void setNamedConstant(const String& name, const Matrix4* m, UINT32 numEntries);
-		/** Sets a Matrix3 parameter to the program.
-		@param name The name of the parameter
-		@param m The value to set
-		*/
-		void setNamedConstant(const String& name, const Matrix3& m);
-		/** Sets a multiple value constant floating-point parameter to the program.
-		@par
-		Some systems only allow constants to be set on certain boundaries, 
-		e.g. in sets of 4 values for example. The 'multiple' parameter allows
-		you to control that although you should only change it if you know
-		your chosen language supports that (at the time of writing, only
-		GLSL allows constants which are not a multiple of 4).
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param name The name of the parameter
-		@param val Pointer to the values to write
-		@param count The number of 'multiples' of floats to write
-		@param multiple The number of raw entries in each element to write, 
-		the default is 4 so count = 1 would write 4 floats.
-		*/
-		void setNamedConstant(const String& name, const float *val, UINT32 count, 
-			UINT32 multiple = 4);
-		/** Sets a multiple value constant floating-point parameter to the program.
-		@par
-		Some systems only allow constants to be set on certain boundaries, 
-		e.g. in sets of 4 values for example. The 'multiple' parameter allows
-		you to control that although you should only change it if you know
-		your chosen language supports that (at the time of writing, only
-		GLSL allows constants which are not a multiple of 4).
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param name The name of the parameter
-		@param val Pointer to the values to write
-		@param count The number of 'multiples' of floats to write
-		@param multiple The number of raw entries in each element to write, 
-		the default is 4 so count = 1 would write 4 floats.
-		*/
-		void setNamedConstant(const String& name, const double *val, UINT32 count, 
-			UINT32 multiple = 4);
-		/** Sets a ColourValue parameter to the program.
-		@param name The name of the parameter
-		@param colour The value to set
-		*/
-		void setNamedConstant(const String& name, const Color& colour);
-
-		/** Sets a multiple value constant floating-point parameter to the program.
-		@par
-		Some systems only allow constants to be set on certain boundaries, 
-		e.g. in sets of 4 values for example. The 'multiple' parameter allows
-		you to control that although you should only change it if you know
-		your chosen language supports that (at the time of writing, only
-		GLSL allows constants which are not a multiple of 4).
-		@note
-		This named option will only work if you are using a parameters object created
-		from a high-level program (HighLevelGpuProgram).
-		@param name The name of the parameter
-		@param val Pointer to the values to write
-		@param count The number of 'multiples' of floats to write
-		@param multiple The number of raw entries in each element to write, 
-		the default is 4 so count = 1 would write 4 floats.
-		*/
-		void setNamedConstant(const String& name, const int *val, UINT32 count, 
-			UINT32 multiple = 4);
-
-		/**
-		 * @brief	Returns true if a named constant with the specified name exists.
-		 */
-		bool hasNamedConstant(const String& name) const;
-
-		/** Find a constant definition for a named parameter.
-		@remarks
-		This method returns null if the named parameter did not exist, unlike
-		getConstantDefinition which is more strict; unless you set the 
-		last parameter to true.
-		@param name The name to look up
-		@param throwExceptionIfMissing If set to true, failure to find an entry
-		will throw an exception.
-		*/
-		const GpuConstantDefinition* _findNamedConstantDefinition(
-			const String& name, bool throwExceptionIfMissing = false) const;
-		/** Gets the physical buffer index associated with a logical float constant index. 
-		@note Only applicable to low-level programs.
-		@param logicalIndex The logical parameter index
-		@param requestedSize The requested size - pass 0 to ignore missing entries
-		and return std::numeric_limits<UINT32>::max() 
-		*/
-		UINT32 _getFloatConstantPhysicalIndex(UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability);
-		/** Gets the physical buffer index associated with a logical int constant index. 
-		@note Only applicable to low-level programs.
-		@param logicalIndex The logical parameter index
-		@param requestedSize The requested size - pass 0 to ignore missing entries
-		and return std::numeric_limits<UINT32>::max() 
-		*/
-		UINT32 _getIntConstantPhysicalIndex(UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability);
-
-		/** Sets whether or not we need to transpose the matrices passed in from the rest of OGRE.
-		@remarks
-		D3D uses transposed matrices compared to GL and OGRE; this is not important when you
-		use programs which are written to process row-major matrices, such as those generated
-		by Cg, but if you use a program written to D3D's matrix layout you will need to enable
-		this flag.
-		*/
-		void setTransposeMatrices(bool val) { mTransposeMatrices = val; } 
-		/// Gets whether or not matrices are to be transposed when set
-		bool getTransposeMatrices(void) const { return mTransposeMatrices; } 
-
-		/** Copies the values of all constants (including auto constants) from another
-		GpuProgramParameters object.
-		@note This copes the internal storage of the paarameters object and therefore
-		can only be used for parameters objects created from the same GpuProgram.
-		To merge parameters that match from different programs, use copyMatchingNamedConstantsFrom.
-		*/
-		void copyConstantsFrom(const GpuProgramParameters& source);
-	};
-
-	/// Shared pointer used to hold references to GpuProgramParameters instances
-	typedef std::shared_ptr<GpuProgramParameters> GpuProgramParametersSharedPtr;
-
-	/** @} */
-	/** @} */
-}
-#endif
-

+ 62 - 54
CamelotCore/Include/CmHardwareBufferManager.h

@@ -9,91 +9,99 @@
 
 namespace BansheeEngine 
 {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup RenderSystem
-	*  @{
-	*/
-
-	/** Base definition of a hardware buffer manager.
-	*/
+	/**
+	 * @brief	Handles creation of various hardware buffers.
+	 *
+	 * @note	Thread safe.
+	 */
 	class CM_EXPORT HardwareBufferManager : public Module<HardwareBufferManager>
 	{
     public:
         HardwareBufferManager();
         virtual ~HardwareBufferManager();
-		/** Create a hardware vertex buffer.
-        @remarks
-            This method creates a new vertex buffer; this will act as a source of geometry
-            data for rendering objects. Note that because the meaning of the contents of
-            the vertex buffer depends on the usage, this method does not specify a
-            vertex format; the user of this buffer can actually insert whatever data 
-            they wish, in any format. However, in order to use this with a RenderOperation,
-            the data in this vertex buffer will have to be associated with a semantic element
-            of the rendering pipeline, e.g. a position, or texture coordinates. This is done 
-            using the VertexDeclaration class, which itself contains VertexElement structures
-            referring to the source data.
-        @remarks Note that because vertex buffers can be shared, they are reference
-            counted so you do not need to worry about destroying themm this will be done
-            automatically.
-        @param vertexSize The size in bytes of each vertex in this buffer; you must calculate
-            this based on the kind of data you expect to populate this buffer with.
-        @param numVerts The number of vertices in this buffer.
-        @param usage One or more members of the HardwareBuffer::Usage enumeration; you are
-            strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to 
-            update regularly, consider HBU_DYNAMIC_WRITE_ONLY and useShadowBuffer=true.
-		@param streamOut Whether the vertex buffer will be used for steam out operations of the
-			geometry shader.
-        */
-		virtual VertexBufferPtr 
-            createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
 
-		/** Create a hardware index buffer.
-        @remarks Note that because buffers can be shared, they are reference
-            counted so you do not need to worry about destroying them this will be done
-            automatically.
-		@param itype The type in index, either 16- or 32-bit, depending on how many vertices
-			you need to be able to address
-		@param numIndexes The number of indexes in the buffer
-        @param usage One or more members of the HardwareBuffer::Usage enumeration.
-        */
-		virtual IndexBufferPtr 
-            createIndexBuffer(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+		/**
+		 * @brief	Creates a new vertex buffer used for holding number of vertices and other
+		 *			per-vertex data. Buffer can be bound to the pipeline and its data can
+		 *			be passed to the active vertex GPU program.
+		 *
+		 * @param	vertexSize	Size of a single vertex in the buffer, in bytes.
+		 * @param	numVerts	Number of vertices the buffer can hold.
+		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
+		 * @param	streamOut	If true the buffer will be usable for streaming out data from the GPU.
+		 */
+		virtual VertexBufferPtr createVertexBuffer(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false);
 
 		/**
-		 * @brief	Creates an GPU parameter block that you can use for setting parameters
-		 * 			for GPU programs.
+		 * @brief	Creates a new index buffer that holds indices referencing vertices in a vertex buffer.
+		 *			Indices are interpreted by the pipeline and vertices are drawn in the order specified in
+		 *			the index buffer.
 		 *
-		 * @return	The new GPU parameter block.
+		 * @param	itype		Index type, determines size of an index.
+		 * @param	numIndexes	Number of indexes can buffer can hold.
+		 * @param	usage		Usage that tells the hardware how will be buffer be used. 
+		 */
+		virtual IndexBufferPtr createIndexBuffer(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage);
+
+		/**
+		 * @brief	Creates an GPU parameter block that you can use for setting parameters for GPU programs.
+		 *			Parameter blocks may be used for sharing parameter data between multiple GPU programs, requiring
+		 *			you to update only one buffer for all of them, potentially improving performance.
+		 *
+		 * @param	size	Size of the parameter buffer in bytes.
+		 * @param	usage	Usage that tells the hardware how will be buffer be used. 
 		 */
 		virtual GpuParamBlockBufferPtr createGpuParamBlockBuffer(UINT32 size, GpuParamBlockUsage usage = GPBU_DYNAMIC);
 
 		/**
-		 * @brief	Creates a generic buffer that can be passed as a parameter to a shader.
+		 * @brief	Creates a generic buffer that can be passed as a parameter to a shader. This type of buffer can hold
+		 *			various type of data and can be used for various purposes. See "GpuBufferType" for explanation of
+		 *			different buffer types.
 		 *
 		 * @param	elementCount  	Number of elements in the buffer. 
 		 * @param	elementSize   	Size of each individual element in the buffer, in bytes.
 		 * @param	type		  	Type of the buffer.
-		 * @param	usage		  	Determines how will the buffer be used.
+		 * @param	usage		  	Usage that tells the hardware how will be buffer be used. 
 		 * @param	randomGpuWrite	(optional) Allows the GPU to write to the resource.
-		 * @param	useCounter	  	(optional) Binds a counter that can be used from a shader to the buffer.
+		 * @param	useCounter	  	(optional) Binds a counter that can be used from a GPU program on the buffer.
 		 *
-		 * Be aware that some of these settings cannot be used together, and you will receive an assert if in debug mode.
+		 * @note	Be aware that due to some render API restrictions some of these settings cannot be used together, 
+		 *			and if so you will receive an assert in debug mode.
 		 */
 		virtual GpuBufferPtr createGpuBuffer(UINT32 elementCount, UINT32 elementSize, 
 			GpuBufferType type, GpuBufferUsage usage, bool randomGpuWrite = false, bool useCounter = false);
 
-        /** Creates a new vertex declaration. */
+		/**
+		 * @brief	Creates a new vertex declaration from a list of vertex elements.
+		 */
 		virtual VertexDeclarationPtr createVertexDeclaration(const VertexDeclaration::VertexElementList& elements);
 
 	protected:
-		virtual VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
+		/**
+		 * @copydoc	createVertexBuffer
+		 */
 		virtual VertexBufferPtr createVertexBufferImpl(UINT32 vertexSize, UINT32 numVerts, GpuBufferUsage usage, bool streamOut = false) = 0;
+
+		/**
+		 * @copydoc	createIndexBuffer
+		 */
 		virtual IndexBufferPtr createIndexBufferImpl(IndexBuffer::IndexType itype, UINT32 numIndexes, GpuBufferUsage usage) = 0;
+
+		/**
+		 * @copydoc	createGpuParamBlockBuffer
+		 */
 		virtual GpuParamBlockBufferPtr createGpuParamBlockBufferImpl() = 0;
+
+		/**
+		 * @copydoc	createGpuBuffer
+		 */
 		virtual GpuBufferPtr createGpuBufferImpl(UINT32 elementCount, UINT32 elementSize, GpuBufferType type, GpuBufferUsage usage, 
 			bool randomGpuWrite = false, bool useCounter = false) = 0;
+
+		/**
+		 * @copydoc	createVertexDeclaration
+		 */
+		virtual VertexDeclarationPtr createVertexDeclarationImpl(const VertexDeclaration::VertexElementList& elements);
 	};
 }
 

+ 0 - 1
CamelotCore/Include/CmMaterialRTTI.h

@@ -8,7 +8,6 @@
 #include "CmMatrix3.h"
 #include "CmMatrix4.h"
 #include "CmMaterial.h"
-#include "CmGpuProgramParams.h"
 #include "CmGpuParams.h"
 #include "CmShader.h"
 #include "CmDebug.h"

+ 27 - 42
CamelotCore/Source/CmGpuProgramManager.cpp

@@ -4,59 +4,50 @@
 namespace BansheeEngine 
 {
 	String sNullLang = "null";
+
+	/**
+	 * @brief	Null GPU program used in place of GPU programs we cannot create.
+	 *			Null programs don't do anything.
+	 */
 	class NullProgram : public GpuProgram
 	{
+	public:
+		NullProgram()
+			:GpuProgram("", "", GPT_VERTEX_PROGRAM, GPP_NONE, nullptr)
+		{ }
+
+		~NullProgram() { }
+
+		bool isSupported() const { return false; }
+		const String& getLanguage() const { return sNullLang; }
+
 	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 loadFromSource() {}
 
-		}
 		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;
-		}
+		{ }
 	};
 
+	/**
+	 * @brief	Factory that creates null GPU programs. 
+	 */
 	class NullProgramFactory : public GpuProgramFactory
 	{
 	public:
 		NullProgramFactory() {}
 		~NullProgramFactory() {}
-		/// Get the name of the language this factory creates programs for
-		const String& getLanguage(void) const 
+
+		const String& getLanguage() const 
 		{ 
 			return sNullLang;
 		}
-		GpuProgramPtr create(const String& source, const String& entryPoint,
-			GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes, 
-			bool requiresAdjacencyInformation)
+
+		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(GpuProgramType type)
 		{
 			return cm_core_ptr<NullProgram, PoolAlloc>();
@@ -76,14 +67,11 @@ namespace BansheeEngine
 
 	void GpuProgramManager::addFactory(GpuProgramFactory* factory)
 	{
-		// deliberately allow later plugins to override earlier ones
 		mFactories[factory->getLanguage()] = factory;
 	}
 
     void GpuProgramManager::removeFactory(GpuProgramFactory* 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)
         {
@@ -96,10 +84,8 @@ namespace BansheeEngine
 		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;
 	}
 
@@ -108,7 +94,6 @@ namespace BansheeEngine
 		FactoryMap::iterator i = mFactories.find(lang);
 
 		return i != mFactories.end();
-
 	}
 
     GpuProgramPtr GpuProgramManager::create(const String& source, const String& entryPoint, const String& language, 

+ 0 - 885
CamelotCore/Source/CmGpuProgramParams.cpp

@@ -1,885 +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 "CmGpuProgramParams.h"
-#include "CmMatrix4.h"
-#include "CmMatrix3.h"
-#include "CmVector2.h"
-#include "CmVector3.h"
-#include "CmVector4.h"
-#include "CmTexture.h"
-#include "CmRenderSystemCapabilities.h"
-#include "CmException.h"
-
-
-namespace BansheeEngine
-{
-
-	bool GpuNamedConstants::msGenerateAllConstantDefinitionArrayEntries = false;
-
-	//---------------------------------------------------------------------
-	void GpuNamedConstants::generateConstantDefinitionArrayEntries(
-		const String& paramName, const GpuConstantDefinition& baseDef)
-	{
-		// Copy definition for use with arrays
-		GpuConstantDefinition arrayDef = baseDef;
-		arrayDef.arraySize = 1;
-		String arrayName;
-
-		// Add parameters for array accessors
-		// [0] will refer to the same location, [1+] will increment
-		// only populate others individually up to 16 array slots so as not to get out of hand,
-		// unless the system has been explicitly configured to allow all the parameters to be added
-
-		// paramName[0] version will always exist 
-		UINT32 maxArrayIndex = 1;
-		if (baseDef.arraySize <= 16 || msGenerateAllConstantDefinitionArrayEntries)
-			maxArrayIndex = baseDef.arraySize;
-
-		for (UINT32 i = 0; i < maxArrayIndex; i++)
-		{
-			arrayName = paramName + "[" + toString(i) + "]";
-			map.insert(GpuConstantDefinitionMap::value_type(arrayName, arrayDef));
-			// increment location
-			arrayDef.physicalIndex += arrayDef.elementSize;
-		}
-		// note no increment of buffer sizes since this is shared with main array def
-
-	}
-
-	//---------------------------------------------------------------------
-	bool GpuNamedConstants::getGenerateAllConstantDefinitionArrayEntries()
-	{
-		return msGenerateAllConstantDefinitionArrayEntries;
-	}
-
-	//---------------------------------------------------------------------
-	void GpuNamedConstants::setGenerateAllConstantDefinitionArrayEntries(bool generateAll)
-	{
-		msGenerateAllConstantDefinitionArrayEntries = generateAll;
-	}    
-	//-----------------------------------------------------------------------------
-	//      GpuProgramParameters Methods
-	//-----------------------------------------------------------------------------
-	GpuProgramParameters::GpuProgramParameters() :
-		mCombinedVariability(GPV_GLOBAL)
-		, mTransposeMatrices(false)
-		, mIgnoreMissingParams(false)
-	{
-	}
-	//-----------------------------------------------------------------------------
-
-	GpuProgramParameters::GpuProgramParameters(const GpuProgramParameters& oth)
-	{
-		*this = oth;
-	}
-
-	//-----------------------------------------------------------------------------
-	GpuProgramParameters& GpuProgramParameters::operator=(const GpuProgramParameters& oth)
-	{
-		// let compiler perform shallow copies of structures 
-		// RealConstantEntry, IntConstantEntry
-		mFloatConstants = oth.mFloatConstants;
-		mIntConstants  = oth.mIntConstants;
-		mSamplerStates = oth.mSamplerStates;
-		mTextures = oth.mTextures;
-		mFloatLogicalToPhysical = oth.mFloatLogicalToPhysical;
-		mIntLogicalToPhysical = oth.mIntLogicalToPhysical;
-		mSamplerLogicalToPhysical = oth.mSamplerLogicalToPhysical;
-		mTextureLogicalToPhysical = oth.mTextureLogicalToPhysical;
-		mNamedConstants = oth.mNamedConstants;
-
-		mCombinedVariability = oth.mCombinedVariability;
-		mTransposeMatrices = oth.mTransposeMatrices;
-		mIgnoreMissingParams  = oth.mIgnoreMissingParams;
-
-		return *this;
-	}
-	//---------------------------------------------------------------------
-	void GpuProgramParameters::_setNamedConstants(
-		const GpuNamedConstantsPtr& namedConstants)
-	{
-		mNamedConstants = namedConstants;
-
-		// Determine any extension to local buffers
-
-		// Size and reset buffer (fill with zero to make comparison later ok)
-		if (namedConstants->floatBufferSize > mFloatConstants.size())
-		{
-			mFloatConstants.insert(mFloatConstants.end(), 
-				namedConstants->floatBufferSize - mFloatConstants.size(), 0.0f);
-		}
-		if (namedConstants->intBufferSize > mIntConstants.size())
-		{
-			mIntConstants.insert(mIntConstants.end(), 
-				namedConstants->intBufferSize - mIntConstants.size(), 0);
-		}
-		if (namedConstants->textureCount > mTextures.size())
-		{
-			mTextures.insert(mTextures.end(), 
-				namedConstants->textureCount - mTextures.size(), HTexture());
-		}
-		if (namedConstants->samplerCount > mSamplerStates.size())
-		{
-			mSamplerStates.insert(mSamplerStates.end(), 
-				namedConstants->samplerCount - mSamplerStates.size(), nullptr);
-		}
-	}
-	//---------------------------------------------------------------------
-	void GpuProgramParameters::_setLogicalIndexes(
-		const GpuLogicalBufferStructPtr& floatIndexMap, 
-		const GpuLogicalBufferStructPtr& intIndexMap,
-		const GpuLogicalBufferStructPtr& samplerIndexMap,
-		const GpuLogicalBufferStructPtr& textureIndexMap)
-	{
-		mFloatLogicalToPhysical = floatIndexMap;
-		mIntLogicalToPhysical = intIndexMap;
-		mSamplerLogicalToPhysical = samplerIndexMap;
-		mTextureLogicalToPhysical = textureIndexMap;
-
-		// resize the internal buffers
-		// Note that these will only contain something after the first parameter
-		// set has set some parameters
-
-		// Size and reset buffer (fill with zero to make comparison later ok)
-		if ((floatIndexMap != nullptr) && floatIndexMap->bufferSize > mFloatConstants.size())
-		{
-			mFloatConstants.insert(mFloatConstants.end(), 
-				floatIndexMap->bufferSize - mFloatConstants.size(), 0.0f);
-		}
-
-		if ((intIndexMap != nullptr) &&  intIndexMap->bufferSize > mIntConstants.size())
-		{
-			mIntConstants.insert(mIntConstants.end(), 
-				intIndexMap->bufferSize - mIntConstants.size(), 0);
-		}
-
-		if ((samplerIndexMap != nullptr) &&  samplerIndexMap->bufferSize > mSamplerStates.size())
-		{
-			mSamplerStates.insert(mSamplerStates.end(), 
-				samplerIndexMap->bufferSize - mSamplerStates.size(), nullptr);
-		}
-
-		if ((textureIndexMap != nullptr) &&  textureIndexMap->bufferSize > mTextures.size())
-		{
-			mTextures.insert(mTextures.end(), 
-				textureIndexMap->bufferSize - mTextures.size(), HTexture());
-		}
-	}
-	//---------------------------------------------------------------------()
-	void GpuProgramParameters::setConstant(UINT32 index, const Vector4& vec)
-	{
-		setConstant(index, vec.ptr(), 1);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, float val)
-	{
-		setConstant(index, Vector4(val, 0.0f, 0.0f, 0.0f));
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, const Vector3& vec)
-	{
-		setConstant(index, Vector4(vec.x, vec.y, vec.z, 1.0f));
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, const Matrix4& m)
-	{
-		// set as 4x 4-element floats
-		if (mTransposeMatrices)
-		{
-			Matrix4 t = m.transpose();
-			GpuProgramParameters::setConstant(index, t[0], 4);
-		}
-		else
-		{
-			GpuProgramParameters::setConstant(index, m[0], 4);
-		}
-
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, const Matrix4* pMatrix, 
-		UINT32 numEntries)
-	{
-		if (mTransposeMatrices)
-		{
-			for (UINT32 i = 0; i < numEntries; ++i)
-			{
-				Matrix4 t = pMatrix[i].transpose();
-				GpuProgramParameters::setConstant(index, t[0], 4);
-				index += 4;
-			}
-		}
-		else
-		{
-			GpuProgramParameters::setConstant(index, pMatrix[0][0], 4 * numEntries);
-		}
-
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, const Color& colour)
-	{
-		setConstant(index, colour.ptr(), 1);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, const float *val, UINT32 count)
-	{
-		// Raw buffer size is 4x count
-		UINT32 rawCount = count * 4;
-		// get physical index
-		assert((mFloatLogicalToPhysical != nullptr) && "GpuProgram hasn't set up the logical -> physical map!");
-
-		UINT32 physicalIndex = _getFloatConstantPhysicalIndex(index, rawCount, GPV_GLOBAL);
-
-		// Copy 
-		_writeRawConstants(physicalIndex, val, rawCount);
-
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, const double *val, UINT32 count)
-	{
-		// Raw buffer size is 4x count
-		UINT32 rawCount = count * 4;
-		// get physical index
-		assert((mFloatLogicalToPhysical != nullptr) && "GpuProgram hasn't set up the logical -> physical map!");
-
-		UINT32 physicalIndex = _getFloatConstantPhysicalIndex(index, rawCount, GPV_GLOBAL);
-		assert(physicalIndex + rawCount <= mFloatConstants.size());
-		// Copy manually since cast required
-		for (UINT32 i = 0; i < rawCount; ++i)
-		{
-			mFloatConstants[physicalIndex + i] = 
-				static_cast<float>(val[i]);
-		}
-
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setConstant(UINT32 index, const int *val, UINT32 count)
-	{
-		// Raw buffer size is 4x count
-		UINT32 rawCount = count * 4;
-		// get physical index
-		assert((mIntLogicalToPhysical != nullptr) && "GpuProgram hasn't set up the logical -> physical map!");
-
-		UINT32 physicalIndex = _getIntConstantPhysicalIndex(index, rawCount, GPV_GLOBAL);
-		// Copy 
-		_writeRawConstants(physicalIndex, val, rawCount);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, const Vector4& vec,
-		UINT32 count)
-	{
-		// remember, raw content access uses raw float count rather than float4
-		// write either the number requested (for packed types) or up to 4
-		_writeRawConstants(physicalIndex, vec.ptr(), std::min(count, (UINT32)4));
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, float val)
-	{
-		_writeRawConstants(physicalIndex, &val, 1);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, int val)
-	{
-		_writeRawConstants(physicalIndex, &val, 1);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, const Vector3& vec)
-	{
-		_writeRawConstants(physicalIndex, vec.ptr(), 3);		
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, const Vector2& vec)
-	{
-		_writeRawConstants(physicalIndex, vec.ptr(), 2);		
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, const Matrix4& m, UINT32 elementCount)
-	{
-
-		// remember, raw content access uses raw float count rather than float4
-		if (mTransposeMatrices)
-		{
-			Matrix4 t = m.transpose();
-			_writeRawConstants(physicalIndex, t[0], elementCount>16?16:elementCount);
-		}
-		else
-		{
-			_writeRawConstants(physicalIndex, m[0], elementCount>16?16:elementCount);
-		}
-
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, const Matrix4* pMatrix, UINT32 numEntries)
-	{
-		// remember, raw content access uses raw float count rather than float4
-		if (mTransposeMatrices)
-		{
-			for (UINT32 i = 0; i < numEntries; ++i)
-			{
-				Matrix4 t = pMatrix[i].transpose();
-				_writeRawConstants(physicalIndex, t[0], 16);
-				physicalIndex += 16;
-			}
-		}
-		else
-		{
-			_writeRawConstants(physicalIndex, pMatrix[0][0], 16 * numEntries);
-		}
-
-
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, const Matrix3& m, UINT32 elementCount)
-	{
-		// remember, raw content access uses raw float count rather than float4
-		if (mTransposeMatrices)
-		{
-			Matrix3 t = m.transpose();
-			_writeRawConstants(physicalIndex, t[0], elementCount>9?9:elementCount);
-		}
-		else
-		{
-			_writeRawConstants(physicalIndex, m[0], elementCount>9?9:elementCount);
-		}
-
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstant(UINT32 physicalIndex, 
-		const Color& colour, UINT32 count)
-	{
-		// write either the number requested (for packed types) or up to 4
-		_writeRawConstants(physicalIndex, colour.ptr(), std::min(count, (UINT32)4));
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstants(UINT32 physicalIndex, const double* val, UINT32 count)
-	{
-		assert(physicalIndex + count <= mFloatConstants.size());
-		for (UINT32 i = 0; i < count; ++i)
-		{
-			mFloatConstants[physicalIndex+i] = static_cast<float>(val[i]);
-		}
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstants(UINT32 physicalIndex, const float* val, UINT32 count)
-	{
-		assert(physicalIndex + count <= mFloatConstants.size());
-		memcpy(&mFloatConstants[physicalIndex], val, sizeof(float) * count);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_writeRawConstants(UINT32 physicalIndex, const int* val, UINT32 count)
-	{
-		assert(physicalIndex + count <= mIntConstants.size());
-		memcpy(&mIntConstants[physicalIndex], val, sizeof(int) * count);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_readRawConstants(UINT32 physicalIndex, UINT32 count, float* dest)
-	{
-		assert(physicalIndex + count <= mFloatConstants.size());
-		memcpy(dest, &mFloatConstants[physicalIndex], sizeof(float) * count);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_readRawConstants(UINT32 physicalIndex, UINT32 count, int* dest)
-	{
-		assert(physicalIndex + count <= mIntConstants.size());
-		memcpy(dest, &mIntConstants[physicalIndex], sizeof(int) * count);
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::_readTexture(UINT32 physicalIndex, HTexture& dest)
-	{
-		assert(physicalIndex < mTextures.size());
-		dest = mTextures[physicalIndex];
-	}
-	//---------------------------------------------------------------------
-	GpuLogicalIndexUse* GpuProgramParameters::_getFloatConstantLogicalIndexUse(
-		UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability)
-	{
-		if (mFloatLogicalToPhysical == nullptr)
-			return 0;
-
-		GpuLogicalIndexUse* indexUse = 0;
-
-		GpuLogicalIndexUseMap::iterator logi = mFloatLogicalToPhysical->map.find(logicalIndex);
-		if (logi == mFloatLogicalToPhysical->map.end())
-		{
-			if (requestedSize)
-			{
-				UINT32 physicalIndex = (UINT32)mFloatConstants.size();
-
-				// Expand at buffer end
-				mFloatConstants.insert(mFloatConstants.end(), requestedSize, 0.0f);
-
-				// Record extended size for future GPU params re-using this information
-				mFloatLogicalToPhysical->bufferSize = (UINT32)mFloatConstants.size();
-
-				// low-level programs will not know about mapping ahead of time, so 
-				// populate it. Other params objects will be able to just use this
-				// accepted mapping since the constant structure will be the same
-
-				// Set up a mapping for all items in the count
-				UINT32 currPhys = physicalIndex;
-				UINT32 count = requestedSize / 4;
-				GpuLogicalIndexUseMap::iterator insertedIterator;
-
-				for (UINT32 logicalNum = 0; logicalNum < count; ++logicalNum)
-				{
-					GpuLogicalIndexUseMap::iterator it = 
-						mFloatLogicalToPhysical->map.insert(
-						GpuLogicalIndexUseMap::value_type(
-						logicalIndex + logicalNum, 
-						GpuLogicalIndexUse(currPhys, requestedSize, variability))).first;
-					currPhys += 4;
-
-					if (logicalNum == 0)
-						insertedIterator = it;
-				}
-
-				indexUse = &(insertedIterator->second);
-			}
-			else
-			{
-				// no match & ignore
-				return 0;
-			}
-
-		}
-		else
-		{
-			UINT32 physicalIndex = logi->second.physicalIndex;
-			indexUse = &(logi->second);
-			// check size
-			if (logi->second.currentSize < requestedSize)
-			{
-				// init buffer entry wasn't big enough; could be a mistake on the part
-				// of the original use, or perhaps a variable length we can't predict
-				// until first actual runtime use e.g. world matrix array
-				UINT32 insertCount = requestedSize - logi->second.currentSize;
-				FloatConstantList::iterator insertPos = mFloatConstants.begin();
-				std::advance(insertPos, physicalIndex);
-				mFloatConstants.insert(insertPos, insertCount, 0.0f);
-				// shift all physical positions after this one
-				for (GpuLogicalIndexUseMap::iterator i = mFloatLogicalToPhysical->map.begin();
-					i != mFloatLogicalToPhysical->map.end(); ++i)
-				{
-					if (i->second.physicalIndex > physicalIndex)
-						i->second.physicalIndex += insertCount;
-				}
-				mFloatLogicalToPhysical->bufferSize += insertCount;
-				if (mNamedConstants != nullptr)
-				{
-					for (GpuConstantDefinitionMap::iterator i = mNamedConstants->map.begin();
-						i != mNamedConstants->map.end(); ++i)
-					{
-						if (i->second.isFloat() && i->second.physicalIndex > physicalIndex)
-							i->second.physicalIndex += insertCount;
-					}
-					mNamedConstants->floatBufferSize += insertCount;
-				}
-
-				logi->second.currentSize += insertCount;
-			}
-		}
-
-		if (indexUse)
-			indexUse->variability = variability;
-
-		return indexUse;
-
-	}
-	//---------------------------------------------------------------------()
-	GpuLogicalIndexUse* GpuProgramParameters::_getIntConstantLogicalIndexUse(UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability)
-	{
-		if (mIntLogicalToPhysical == nullptr)
-		{
-			CM_EXCEPT(InvalidParametersException, 
-			"This is not a low-level parameter parameter object");
-		}
-
-		GpuLogicalIndexUse* indexUse = 0;
-
-		GpuLogicalIndexUseMap::iterator logi = mIntLogicalToPhysical->map.find(logicalIndex);
-		if (logi == mIntLogicalToPhysical->map.end())
-		{
-			if (requestedSize)
-			{
-				UINT32 physicalIndex = (UINT32)mIntConstants.size();
-
-				// Expand at buffer end
-				mIntConstants.insert(mIntConstants.end(), requestedSize, 0);
-
-				// Record extended size for future GPU params re-using this information
-				mIntLogicalToPhysical->bufferSize = (UINT32)mIntConstants.size();
-
-				// low-level programs will not know about mapping ahead of time, so 
-				// populate it. Other params objects will be able to just use this
-				// accepted mapping since the constant structure will be the same
-
-				// Set up a mapping for all items in the count
-				UINT32 currPhys = physicalIndex;
-				UINT32 count = requestedSize / 4;
-				GpuLogicalIndexUseMap::iterator insertedIterator;
-				for (UINT32 logicalNum = 0; logicalNum < count; ++logicalNum)
-				{
-					GpuLogicalIndexUseMap::iterator it = 
-						mIntLogicalToPhysical->map.insert(
-						GpuLogicalIndexUseMap::value_type(
-						logicalIndex + logicalNum, 
-						GpuLogicalIndexUse(currPhys, requestedSize, variability))).first;
-					if (logicalNum == 0)
-						insertedIterator = it;
-					currPhys += 4;
-				}
-				indexUse = &(insertedIterator->second);
-
-			}
-			else
-			{
-				// no match
-				return 0;
-			}
-
-		}
-		else
-		{
-			UINT32 physicalIndex = logi->second.physicalIndex;
-			indexUse = &(logi->second);
-
-			// check size
-			if (logi->second.currentSize < requestedSize)
-			{
-				// init buffer entry wasn't big enough; could be a mistake on the part
-				// of the original use, or perhaps a variable length we can't predict
-				// until first actual runtime use e.g. world matrix array
-				UINT32 insertCount = requestedSize - logi->second.currentSize;
-				IntConstantList::iterator insertPos = mIntConstants.begin();
-				std::advance(insertPos, physicalIndex);
-				mIntConstants.insert(insertPos, insertCount, 0);
-				// shift all physical positions after this one
-				for (GpuLogicalIndexUseMap::iterator i = mIntLogicalToPhysical->map.begin();
-					i != mIntLogicalToPhysical->map.end(); ++i)
-				{
-					if (i->second.physicalIndex > physicalIndex)
-						i->second.physicalIndex += insertCount;
-				}
-				mIntLogicalToPhysical->bufferSize += insertCount;
-				if (mNamedConstants != nullptr)
-				{
-					for (GpuConstantDefinitionMap::iterator i = mNamedConstants->map.begin();
-						i != mNamedConstants->map.end(); ++i)
-					{
-						if (!i->second.isFloat() && i->second.physicalIndex > physicalIndex)
-							i->second.physicalIndex += insertCount;
-					}
-					mNamedConstants->intBufferSize += insertCount;
-				}
-
-				logi->second.currentSize += insertCount;
-			}
-		}
-
-		if (indexUse)
-			indexUse->variability = variability;
-
-		return indexUse;
-
-	}
-	//-----------------------------------------------------------------------------
-	UINT32 GpuProgramParameters::_getFloatConstantPhysicalIndex(
-		UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability) 
-	{
-		GpuLogicalIndexUse* indexUse = _getFloatConstantLogicalIndexUse(logicalIndex, requestedSize, variability);
-		return indexUse ? indexUse->physicalIndex : 0;
-	}
-	//-----------------------------------------------------------------------------
-	UINT32 GpuProgramParameters::_getIntConstantPhysicalIndex(
-		UINT32 logicalIndex, UINT32 requestedSize, UINT16 variability)
-	{
-		GpuLogicalIndexUse* indexUse = _getIntConstantLogicalIndexUse(logicalIndex, requestedSize, variability);
-		return indexUse ? indexUse->physicalIndex : 0;
-	}
-	//-----------------------------------------------------------------------------
-	UINT32 GpuProgramParameters::getFloatLogicalIndexForPhysicalIndex(UINT32 physicalIndex)
-	{
-		// perhaps build a reverse map of this sometime (shared in GpuProgram)
-		for (GpuLogicalIndexUseMap::iterator i = mFloatLogicalToPhysical->map.begin();
-			i != mFloatLogicalToPhysical->map.end(); ++i)
-		{
-			if (i->second.physicalIndex == physicalIndex)
-				return i->first;
-		}
-		return std::numeric_limits<UINT32>::max();
-
-	}
-	//-----------------------------------------------------------------------------
-	UINT32 GpuProgramParameters::getIntLogicalIndexForPhysicalIndex(UINT32 physicalIndex)
-	{
-		// perhaps build a reverse map of this sometime (shared in GpuProgram)
-		for (GpuLogicalIndexUseMap::iterator i = mIntLogicalToPhysical->map.begin();
-			i != mIntLogicalToPhysical->map.end(); ++i)
-		{
-			if (i->second.physicalIndex == physicalIndex)
-				return i->first;
-		}
-		return std::numeric_limits<UINT32>::max();
-
-	}
-	//-----------------------------------------------------------------------------
-	GpuConstantDefinitionIterator GpuProgramParameters::getConstantDefinitionIterator(void) const
-	{
-		if (mNamedConstants == nullptr)
-		{
-			CM_EXCEPT(InvalidParametersException, 
-			"This params object is not based on a program with named parameters.");
-		}
-
-		return mNamedConstants->map.begin();
-
-	}
-	//-----------------------------------------------------------------------------
-	const GpuNamedConstants& GpuProgramParameters::getConstantDefinitions() const
-	{
-		if (mNamedConstants == nullptr)
-		{
-			CM_EXCEPT(InvalidParametersException, 
-			"This params object is not based on a program with named parameters.");
-		}
-
-		return *mNamedConstants;
-	}
-	//-----------------------------------------------------------------------------
-	const GpuConstantDefinition& GpuProgramParameters::getConstantDefinition(const String& name) const
-	{
-		if (mNamedConstants == nullptr)
-		{
-			CM_EXCEPT(InvalidParametersException, 
-			"This params object is not based on a program with named parameters.");
-		}
-
-
-		// locate, and throw exception if not found
-		const GpuConstantDefinition* def = _findNamedConstantDefinition(name, true);
-
-		return *def;
-	}
-	//----------------------------------------------------------------------------
-	HTexture GpuProgramParameters::getTexture(UINT32 pos) const 
-	{ 
-		if(!mTextures[pos].isLoaded())
-		{
-			return HTexture();
-		}
-
-		return mTextures[pos]; 
-	}
-	//----------------------------------------------------------------------------
-	SamplerStatePtr GpuProgramParameters::getSamplerState(UINT32 pos) const 
-	{ 
-		return mSamplerStates[pos]; 
-	}
-	//-----------------------------------------------------------------------------
-	bool GpuProgramParameters::hasNamedConstant(const String& name) const
-	{
-		return _findNamedConstantDefinition(name) != nullptr;
-	}
-	//-----------------------------------------------------------------------------
-	const GpuConstantDefinition* 
-		GpuProgramParameters::_findNamedConstantDefinition(const String& name, 
-		bool throwExceptionIfNotFound) const
-	{
-		if (mNamedConstants == nullptr)
-		{
-			if (throwExceptionIfNotFound)
-			{
-				CM_EXCEPT(InvalidParametersException, 
-				"Named constants have not been initialised, perhaps a compile error.");
-			}
-
-			return 0;
-		}
-
-		GpuConstantDefinitionMap::const_iterator i = mNamedConstants->map.find(name);
-		if (i == mNamedConstants->map.end())
-		{
-			if (throwExceptionIfNotFound)
-			{
-				CM_EXCEPT(InvalidParametersException, 
-				"Parameter called " + name + " does not exist. ");
-			}
-
-			return 0;
-		}
-		else
-		{
-			return &(i->second);
-		}
-	}
-	//----------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, HTexture val)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-
-		if (def)
-			mTextures[def->physicalIndex] = val;
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, SamplerStatePtr val)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-
-		if (def)
-			mSamplerStates[def->physicalIndex] = val;
-	}
-	//-----------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, float val)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, val);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, int val)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, val);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, const Vector4& vec)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, vec, def->elementSize);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, const Vector3& vec)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, vec);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, const Vector2& vec)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, vec);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, const Matrix4& m)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, m, def->elementSize);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, const Matrix4* m, 
-		UINT32 numEntries)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, m, numEntries);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, const Matrix3& m)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, m, def->elementSize);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, 
-		const float *val, UINT32 count, UINT32 multiple)
-	{
-		UINT32 rawCount = count * multiple;
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstants(def->physicalIndex, val, rawCount);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, 
-		const double *val, UINT32 count, UINT32 multiple)
-	{
-		UINT32 rawCount = count * multiple;
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstants(def->physicalIndex, val, rawCount);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, const Color& colour)
-	{
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstant(def->physicalIndex, colour, def->elementSize);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::setNamedConstant(const String& name, 
-		const int *val, UINT32 count, UINT32 multiple)
-	{
-		UINT32 rawCount = count * multiple;
-		// look up, and throw an exception if we're not ignoring missing
-		const GpuConstantDefinition* def = 
-			_findNamedConstantDefinition(name, !mIgnoreMissingParams);
-		if (def)
-			_writeRawConstants(def->physicalIndex, val, rawCount);
-	}
-	//---------------------------------------------------------------------------
-	void GpuProgramParameters::copyConstantsFrom(const GpuProgramParameters& source)
-	{
-		// Pull buffers & auto constant list over directly
-		mFloatConstants = source.getFloatConstantList();
-		mIntConstants = source.getIntConstantList();
-		mTextures = source.getTextureList();
-		mSamplerStates = source.getSamplerStateList();
-		mCombinedVariability = source.mCombinedVariability;
-	}
-}
-

+ 0 - 1
CamelotCore/Source/CmMaterial.cpp

@@ -4,7 +4,6 @@
 #include "CmTechnique.h"
 #include "CmPass.h"
 #include "CmRenderSystem.h"
-#include "CmGpuProgramParams.h"
 #include "CmHardwareBufferManager.h"
 #include "CmGpuProgram.h"
 #include "CmGpuParamBlockBuffer.h"