Forráskód Böngészése

Removed some unused param stuff

Marko Pintera 13 éve
szülő
commit
2f72100575

+ 0 - 1
CamelotD3D9Renderer/Include/CmD3D9GpuProgram.h

@@ -74,7 +74,6 @@ namespace CamelotEngine {
 		/** Loads this program from microcode, must be overridden by subclasses. */
         virtual void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) = 0;
 
-
         /** Creates a new parameters object compatible with this program definition. 
         @remarks
             It is recommended that you use this method of creating parameters objects

+ 0 - 7
CamelotD3D9Renderer/Include/CmD3D9HLSLProgram.h

@@ -98,18 +98,11 @@ namespace CamelotEngine {
 		 * @copydoc GpuProgram::unload_internal()
 		 */
         void unload_internal(void);
-        /// Populate the passed parameters with name->index map, must be overridden
-        void buildConstantDefinitions() const;
-
-        // Recursive utility method for buildParamNameMap
-        void processParamElement(D3DXHANDLE parent, String prefix, unsigned int index) const;
-		void populateDef(D3DXCONSTANT_DESC& d3dDesc, GpuConstantDefinition& def) const;
 
         String mPreprocessorDefines;
         bool mColumnMajorMatrices;
 
         LPD3DXBUFFER mpMicroCode;
-        LPD3DXCONSTANTTABLE mpConstTable;
 
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/

+ 7 - 265
CamelotD3D9Renderer/Source/CmD3D9HLSLProgram.cpp

@@ -464,6 +464,7 @@ namespace CamelotEngine {
 
 		// include handler
 		HLSLIncludeHandler includeHandler(this);
+		LPD3DXCONSTANTTABLE constTable;
 
 		String hlslProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
 
@@ -478,7 +479,7 @@ namespace CamelotEngine {
             compileFlags,
             &mpMicroCode,
             &errors,
-            &mpConstTable);
+            &constTable);
 
         if (FAILED(hr))
         {
@@ -508,289 +509,30 @@ namespace CamelotEngine {
 			static_cast<D3D9GpuProgram*>(mAssemblerProgram.get())->setExternalMicrocode(mpMicroCode);
 		}
 
-		D3D9HLSLParamParser paramParser(mpConstTable);
+		D3D9HLSLParamParser paramParser(constTable);
 		mParametersDesc = paramParser.buildParameterDescriptions();
+
+		SAFE_RELEASE(constTable);
     }
     //-----------------------------------------------------------------------
     void D3D9HLSLProgram::unload_internal(void)
     {
         SAFE_RELEASE(mpMicroCode);
-        SAFE_RELEASE(mpConstTable);
-
+        
 		HighLevelGpuProgram::unload_internal();
     }
 	//-----------------------------------------------------------------------
-
-    //-----------------------------------------------------------------------
-    void D3D9HLSLProgram::buildConstantDefinitions() const
-    {
-        // Derive parameter names from const table
-        assert(mpConstTable && "Program not loaded!");
-        // Get contents of the constant table
-        D3DXCONSTANTTABLE_DESC desc;
-        HRESULT hr = mpConstTable->GetDesc(&desc);
-
-		createParameterMappingStructures(true);
-
-        if (FAILED(hr))
-        {
-			CM_EXCEPT(InternalErrorException, "Cannot retrieve constant descriptions from HLSL program.");
-        }
-        // Iterate over the constants
-        for (unsigned int i = 0; i < desc.Constants; ++i)
-        {
-            // Recursively descend through the structure levels
-            processParamElement(NULL, "", i);
-        }
-    }
-    //-----------------------------------------------------------------------
-    void D3D9HLSLProgram::processParamElement(D3DXHANDLE parent, String prefix, 
-        unsigned int index) const
-    {
-        D3DXHANDLE hConstant = mpConstTable->GetConstant(parent, index);
-		
-        // Since D3D HLSL doesn't deal with naming of array and struct parameters
-        // automatically, we have to do it by hand
-
-        D3DXCONSTANT_DESC desc;
-        unsigned int numParams = 1;
-        HRESULT hr = mpConstTable->GetConstantDesc(hConstant, &desc, &numParams);
-        if (FAILED(hr))
-        {
-            CM_EXCEPT(InternalErrorException, "Cannot retrieve constant description from HLSL program.");
-        }
-
-        String paramName = desc.Name;
-        // trim the odd '$' which appears at the start of the names in HLSL
-        if (paramName.at(0) == '$')
-            paramName.erase(paramName.begin());
-
-		// Also trim the '[0]' suffix if it exists, we will add our own indexing later
-		if (StringUtil::endsWith(paramName, "[0]", false))
-		{
-			paramName.erase(paramName.size() - 3);
-		}
-
-
-        if (desc.Class == D3DXPC_STRUCT)
-        {
-            // work out a new prefix for nested members, if it's an array, we need an index
-            prefix = prefix + paramName + ".";
-            // Cascade into struct
-            for (unsigned int i = 0; i < desc.StructMembers; ++i)
-            {
-                processParamElement(hConstant, prefix, i);
-            }
-        }
-        else
-        {
-            // Process params
-            if (desc.Type == D3DXPT_FLOAT || desc.Type == D3DXPT_INT || desc.Type == D3DXPT_BOOL ||
-				desc.Type == D3DXPT_SAMPLER1D || desc.Type == D3DXPT_SAMPLER2D || desc.Type == D3DXPT_SAMPLER3D || desc.Type == D3DXPT_SAMPLERCUBE)
-            {
-                UINT32 paramIndex = desc.RegisterIndex;
-                String name = prefix + paramName;
-                
-				GpuConstantDefinition def;
-				def.logicalIndex = paramIndex;
-				// populate type, array size & element size
-				populateDef(desc, def);
-
-				if(def.isSampler())
-				{
-					def.physicalIndex = mSamplerLogicalToPhysical->bufferSize;
-						mSamplerLogicalToPhysical->map.insert(
-						GpuLogicalIndexUseMap::value_type(paramIndex, 
-						GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
-					mSamplerLogicalToPhysical->bufferSize += def.arraySize;
-					mConstantDefs->samplerCount = mSamplerLogicalToPhysical->bufferSize;
-
-						mTextureLogicalToPhysical->map.insert(
-						GpuLogicalIndexUseMap::value_type(paramIndex, 
-						GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
-					mTextureLogicalToPhysical->bufferSize += def.arraySize;
-					mConstantDefs->textureCount = mTextureLogicalToPhysical->bufferSize;
-				}
-				else
-				{
-					if (def.isFloat())
-					{
-						def.physicalIndex = mFloatLogicalToPhysical->bufferSize;
-							mFloatLogicalToPhysical->map.insert(
-							GpuLogicalIndexUseMap::value_type(paramIndex, 
-							GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
-						mFloatLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
-						mConstantDefs->floatBufferSize = mFloatLogicalToPhysical->bufferSize;
-					}
-					else
-					{
-						def.physicalIndex = mIntLogicalToPhysical->bufferSize;
-							mIntLogicalToPhysical->map.insert(
-							GpuLogicalIndexUseMap::value_type(paramIndex, 
-							GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
-						mIntLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
-						mConstantDefs->intBufferSize = mIntLogicalToPhysical->bufferSize;
-					}
-				}
-
-                mConstantDefs->map.insert(GpuConstantDefinitionMap::value_type(name, def));
-
-				// Now deal with arrays
-				mConstantDefs->generateConstantDefinitionArrayEntries(name, def);
-            }
-        }
-            
-    }
-	//-----------------------------------------------------------------------
-	void D3D9HLSLProgram::populateDef(D3DXCONSTANT_DESC& d3dDesc, GpuConstantDefinition& def) const
-	{
-		def.arraySize = d3dDesc.Elements;
-		switch(d3dDesc.Type)
-		{
-		case D3DXPT_SAMPLER1D:
-			def.constType = GCT_SAMPLER1D;
-			break;
-		case D3DXPT_SAMPLER2D:
-			def.constType = GCT_SAMPLER2D;
-			break;
-		case D3DXPT_SAMPLER3D:
-			def.constType = GCT_SAMPLER3D;
-			break;
-		case D3DXPT_SAMPLERCUBE:
-			def.constType = GCT_SAMPLERCUBE;
-			break;
-		case D3DXPT_INT:
-			switch(d3dDesc.Columns)
-			{
-			case 1:
-				def.constType = GCT_INT1;
-				break;
-			case 2:
-				def.constType = GCT_INT2;
-				break;
-			case 3:
-				def.constType = GCT_INT3;
-				break;
-			case 4:
-				def.constType = GCT_INT4;
-				break;
-			} // columns
-			break;
-		case D3DXPT_FLOAT:
-			switch(d3dDesc.Class)
-			{
-			case D3DXPC_MATRIX_COLUMNS:
-			case D3DXPC_MATRIX_ROWS:
-				{
-					int firstDim, secondDim;
-					firstDim = d3dDesc.RegisterCount / d3dDesc.Elements;
-					if (d3dDesc.Class == D3DXPC_MATRIX_ROWS)
-					{
-						secondDim = d3dDesc.Columns;
-					}
-					else
-					{
-						secondDim = d3dDesc.Rows;
-					}
-					switch(firstDim)
-					{
-					case 2:
-						switch(secondDim)
-						{
-						case 2:
-							def.constType = GCT_MATRIX_2X2;
-							def.elementSize = 8; // HLSL always packs
-							break;
-						case 3:
-							def.constType = GCT_MATRIX_2X3;
-							def.elementSize = 8; // HLSL always packs
-							break;
-						case 4:
-							def.constType = GCT_MATRIX_2X4;
-							def.elementSize = 8; 
-							break;
-						} // columns
-						break;
-					case 3:
-						switch(secondDim)
-						{
-						case 2:
-							def.constType = GCT_MATRIX_3X2;
-							def.elementSize = 12; // HLSL always packs
-							break;
-						case 3:
-							def.constType = GCT_MATRIX_3X3;
-							def.elementSize = 12; // HLSL always packs
-							break;
-						case 4:
-							def.constType = GCT_MATRIX_3X4;
-							def.elementSize = 12; 
-							break;
-						} // columns
-						break;
-					case 4:
-						switch(secondDim)
-						{
-						case 2:
-							def.constType = GCT_MATRIX_4X2;
-							def.elementSize = 16; // HLSL always packs
-							break;
-						case 3:
-							def.constType = GCT_MATRIX_4X3;
-							def.elementSize = 16; // HLSL always packs
-							break;
-						case 4:
-							def.constType = GCT_MATRIX_4X4;
-							def.elementSize = 16; 
-							break;
-						} // secondDim
-						break;
-
-					} // firstDim
-				}
-				break;
-			case D3DXPC_SCALAR:
-			case D3DXPC_VECTOR:
-				switch(d3dDesc.Columns)
-				{
-				case 1:
-					def.constType = GCT_FLOAT1;
-					break;
-				case 2:
-					def.constType = GCT_FLOAT2;
-					break;
-				case 3:
-					def.constType = GCT_FLOAT3;
-					break;
-				case 4:
-					def.constType = GCT_FLOAT4;
-					break;
-				} // columns
-				break;
-			}
-		default:
-			// not mapping samplers, don't need to take the space 
-			break;
-		};
-
-		// D3D9 pads to 4 elements
-		def.elementSize = GpuConstantDefinition::getElementSize(def.constType, true);
-
-
-	}
-
 	LPD3DXBUFFER D3D9HLSLProgram::getMicroCode()
 	{
 		return mpMicroCode;
 	}
-
     //-----------------------------------------------------------------------
 	D3D9HLSLProgram::D3D9HLSLProgram(const String& source, const String& entryPoint, const String& language, 
 		GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
         : HighLevelGpuProgram(source, entryPoint, language, gptype, profile, isAdjacencyInfoRequired)
         , mPreprocessorDefines()
         , mColumnMajorMatrices(true)
-        , mpMicroCode(NULL), mpConstTable(NULL)
+        , mpMicroCode(NULL)
 		, mOptimisationLevel(OPT_DEFAULT)
 	{
     }

+ 0 - 41
CamelotRenderer/Include/CmGpuProgram.h

@@ -81,31 +81,6 @@ namespace CamelotEngine {
         String mSyntaxCode;
 		/// Did we encounter a compilation error?
 		bool mCompileError;
-		/** Record of logical to physical buffer maps. Mandatory for low-level
-			programs or high-level programs which set their params the same way. 
-			This is a shared pointer because if the program is recompiled and the parameters
-			change, this definition will alter, but previous params may reference the old def. */
-		mutable GpuLogicalBufferStructPtr mFloatLogicalToPhysical;
-		/** Record of logical to physical buffer maps. Mandatory for low-level
-			programs or high-level programs which set their params the same way. 
-			This is a shared pointer because if the program is recompiled and the parameters
-			change, this definition will alter, but previous params may reference the old def.*/
-		mutable GpuLogicalBufferStructPtr mIntLogicalToPhysical;
-		/** Record of logical to physical buffer maps. Mandatory for low-level
-			programs or high-level programs which set their params the same way. 
-			This is a shared pointer because if the program is recompiled and the parameters
-			change, this definition will alter, but previous params may reference the old def.*/
-		mutable GpuLogicalBufferStructPtr mSamplerLogicalToPhysical;
-		/** Record of logical to physical buffer maps. Mandatory for low-level
-			programs or high-level programs which set their params the same way. 
-			This is a shared pointer because if the program is recompiled and the parameters
-			change, this definition will alter, but previous params may reference the old def.*/
-		mutable GpuLogicalBufferStructPtr mTextureLogicalToPhysical;
-		/** Parameter name -> ConstantDefinition map, shared instance used by all parameter objects.
-		This is a shared pointer because if the program is recompiled and the parameters
-		change, this definition will alter, but previous params may reference the old def.
-		*/
-		mutable GpuNamedConstantsPtr mConstantDefs;
 
 		/**
 		 * @brief	Contains information about all parameters in a shader.
@@ -119,13 +94,6 @@ namespace CamelotEngine {
 		/// @copydoc Resource::calculateSize
 		size_t calculateSize(void) const { return 0; } // TODO 
 
-		/// Create the internal params logical & named mapping structures
-		void createParameterMappingStructures(bool recreateIfExists = true) const;
-		/// Create the internal params logical mapping structures
-		void createLogicalParameterMappingStructures(bool recreateIfExists = true) const;
-		/// Create the internal params named mapping structures
-		void createNamedParameterMappingStructures(bool recreateIfExists = true) const;
-
 		void throwIfNotRenderThread() const;
 
 	public:
@@ -199,15 +167,6 @@ namespace CamelotEngine {
 		*/
 		virtual void resetCompileError(void) { mCompileError = false; }
 
-		/** Get the full list of named constants.
-		@note
-		Only available if this parameters object has named parameters, which means either
-		a high-level program which loads them, or a low-level program which has them
-		specified manually.
-		*/
-		virtual const GpuNamedConstants& getConstantDefinitions_internal() const;
-
-
     protected:
 		friend class GpuProgramManager;
 

+ 0 - 18
CamelotRenderer/Include/CmHighLevelGpuProgram.h

@@ -86,12 +86,6 @@ namespace CamelotEngine {
         /** @copydoc GpuProgram::getBindingDelegate */
         GpuProgram* getBindingDelegate_internal(void) { return mAssemblerProgram.get(); }
 
-		/** Get the full list of GpuConstantDefinition instances.
-		@note
-		Only available if this parameters object has named parameters.
-		*/
-		const GpuNamedConstants& getConstantDefinitions_internal() const;
-
     protected:
 		/** Constructor, should be used only by factory classes. */
 		HighLevelGpuProgram(const String& source, const String& entryPoint, const String& language, 
@@ -99,18 +93,6 @@ namespace CamelotEngine {
 
         /// The underlying assembler program
         GpuProgramPtr mAssemblerProgram;
-		/// Have we built the name->index parameter map yet?
-		mutable bool mConstantDefsBuilt;
-
-        /// Populate the passed parameters with name->index map
-        virtual void populateParameterNames(GpuProgramParametersSharedPtr params);
-		/** Build the constant definition map, must be overridden.
-		@note The implementation must fill in the (inherited) mConstantDefs field at a minimum, 
-			and if the program requires that parameters are bound using logical 
-			parameter indexes then the mFloatLogicalToPhysical and mIntLogicalToPhysical
-			maps must also be populated.
-		*/
-		virtual void buildConstantDefinitions() const = 0;
 
 		/************************************************************************/
 		/* 								STATICS		                     		*/

+ 21 - 15
CamelotRenderer/Include/CmMaterial.h

@@ -12,6 +12,20 @@ namespace CamelotEngine
 		GpuParamsPtr mVertParams;
 		GpuParamsPtr mFragParams;
 		GpuParamsPtr mGeomParams;
+		GpuParamsPtr mHullParams;
+		GpuParamsPtr mDomainParams;
+		GpuParamsPtr mComputeParams;
+
+		// Helper method
+		GpuParamsPtr& getParamByIdx(UINT32 idx)
+		{
+			GpuParamsPtr* paramArray[] = {&mVertParams, &mFragParams, &mGeomParams, &mHullParams, &mDomainParams, &mComputeParams};
+
+			return *paramArray[idx];
+		}
+
+		// Helper method
+		UINT32 getNumParams() const { return 6; }
 	};
 
 	class CM_EXPORT Material : public Resource
@@ -66,22 +80,14 @@ namespace CamelotEngine
 			{
 				PassParametersPtr params = *iter;
 
-				if(params->mVertParams)
-				{
-					if(params->mVertParams->hasParam(name))
-						params->mVertParams->setParam(name, value);
-				}
-
-				if(params->mFragParams)
-				{
-					if(params->mFragParams->hasParam(name))
-						params->mFragParams->setParam(name, value);
-				}
-
-				if(params->mGeomParams)
+				for(UINT32 i = 0; i < params->getNumParams(); i++)
 				{
-					if(params->mGeomParams->hasParam(name))
-						params->mGeomParams->setParam(name, value);
+					GpuParamsPtr& paramPtr = params->getParamByIdx(i);
+					if(paramPtr)
+					{
+						if(paramPtr->hasParam(name))
+							paramPtr->setParam(name, value);
+					}
 				}
 			}
 		}

+ 39 - 18
CamelotRenderer/Include/CmPass.h

@@ -21,12 +21,12 @@ namespace CamelotEngine
 		RasterizerStatePtr mRasterizerState;
 		DepthStencilStatePtr mDepthStencilState;
 
-		// Vertex program
 		GpuProgramHandle mVertexProgram;
-		// Fragment program
 		GpuProgramHandle mFragmentProgram;
-		// Geometry program
 		GpuProgramHandle mGeometryProgram;
+		GpuProgramHandle mHullProgram;
+		GpuProgramHandle mDomainProgram;
+		GpuProgramHandle mComputeProgram;
     public:
         /// Default constructor
 		Pass();
@@ -36,12 +36,12 @@ namespace CamelotEngine
         Pass& operator=(const Pass& oth);
         virtual ~Pass();
 
-        /// Returns true if this pass uses a programmable vertex pipeline
-        bool hasVertexProgram(void) const { return mVertexProgram != nullptr; }
-        /// Returns true if this pass uses a programmable fragment pipeline
-        bool hasFragmentProgram(void) const { return mFragmentProgram != nullptr; }
-        /// Returns true if this pass uses a programmable geometry pipeline
-        bool hasGeometryProgram(void) const { return mGeometryProgram != nullptr; }
+        bool hasVertexProgram() const { return mVertexProgram != nullptr; }
+        bool hasFragmentProgram() const { return mFragmentProgram != nullptr; }
+        bool hasGeometryProgram() const { return mGeometryProgram != nullptr; }
+		bool hasHullProgram() const { return mHullProgram != nullptr; }
+		bool hasDomainProgram() const { return mDomainProgram != nullptr; }
+		bool hasComputeProgram() const { return mComputeProgram != nullptr; }
 
 		/** Returns true if this pass has some element of transparency. */
 		bool isTransparent(void) const;
@@ -60,24 +60,45 @@ namespace CamelotEngine
 
 		/** Sets the details of the vertex program to use.
 		*/
-		void setVertexProgram(GpuProgramHandle gpuProgram);
+		void setVertexProgram(GpuProgramHandle gpuProgram) { mVertexProgram = gpuProgram; }
 
-		/** Gets the vertex program used by this pass, only available after _load(). */
-		const GpuProgramHandle& getVertexProgram(void) const;
+		/** Gets the vertex program used by this pass. */
+		const GpuProgramHandle& getVertexProgram(void) const { return mVertexProgram; }
 
 		/** Sets the details of the fragment program to use.
 		*/
-		void setFragmentProgram(GpuProgramHandle gpuProgram);
+		void setFragmentProgram(GpuProgramHandle gpuProgram) { mFragmentProgram = gpuProgram; }
 		
-		/** Gets the fragment program used by this pass, only available after _load(). */
-		const GpuProgramHandle& getFragmentProgram(void) const;
+		/** Gets the fragment program used by this pass. */
+		const GpuProgramHandle& getFragmentProgram(void) const { return mFragmentProgram; }
 
 		/** Sets the details of the geometry program to use.
 		*/
-		void setGeometryProgram(GpuProgramHandle gpuProgram);
+		void setGeometryProgram(GpuProgramHandle gpuProgram) { mGeometryProgram = gpuProgram; }
 		
-		/** Gets the geometry program used by this pass, only available after _load(). */
-		const GpuProgramHandle& getGeometryProgram(void) const;
+		/** Gets the geometry program used by this pass. */
+		const GpuProgramHandle& getGeometryProgram(void) const { return mGeometryProgram; }
+
+		/** Sets the details of the hull program to use.
+		*/
+		void setHullProgram(GpuProgramHandle gpuProgram) { mHullProgram = gpuProgram; }
+		
+		/** Gets the hull program used by this pass. */
+		const GpuProgramHandle& getHullProgram(void) const { return mHullProgram; }
+
+		/** Sets the details of the domain program to use.
+		*/
+		void setDomainProgram(GpuProgramHandle gpuProgram) { mDomainProgram = gpuProgram;}
+		
+		/** Gets the domain program used by this pass. */
+		const GpuProgramHandle& getDomainProgram(void) const { return mDomainProgram; }
+
+		/** Sets the details of the compute program to use.
+		*/
+		void setComputeProgram(GpuProgramHandle gpuProgram) { mComputeProgram = gpuProgram; }
+		
+		/** Gets the compute program used by this pass. */
+		const GpuProgramHandle& getComputeProgram(void) const { return mComputeProgram; }
 
 		/************************************************************************/
 		/* 								RTTI		                     		*/

+ 144 - 144
CamelotRenderer/Source/CmCgProgram.cpp

@@ -205,7 +205,7 @@ namespace CamelotEngine {
     void CgProgram::buildConstantDefinitions() const
     {
         // Derive parameter names from Cg
-		createParameterMappingStructures(true);
+		//createParameterMappingStructures(true);
 
 		if (!mCgProgram)
 			return;
@@ -216,149 +216,149 @@ namespace CamelotEngine {
 	//---------------------------------------------------------------------
 	void CgProgram::recurseParams(CGparameter parameter, UINT32 contextArraySize) const
 	{
-		while (parameter != 0)
-        {
-            // Look for parameters
-            // Don't bother enumerating unused parameters, especially since they will
-            // be optimised out and therefore not in the indexed versions
-            CGtype paramType = cgGetParameterType(parameter);
-
-            if (cgGetParameterVariability(parameter) == CG_UNIFORM &&
-                paramType != CG_SAMPLERRECT &&
-                cgGetParameterDirection(parameter) != CG_OUT && 
-                cgIsParameterReferenced(parameter))
-            {
-				int arraySize;
-
-				switch(paramType)
-				{
-				case CG_STRUCT:
-					recurseParams(cgGetFirstStructParameter(parameter));
-					break;
-				case CG_ARRAY:
-					// Support only 1-dimensional arrays
-					arraySize = cgGetArraySize(parameter, 0);
-					recurseParams(cgGetArrayParameter(parameter, 0), (size_t)arraySize);
-					break;
-				default:
-					// Normal path (leaf)
-					String paramName = cgGetParameterName(parameter);
-					UINT32 logicalIndex = (UINT32)cgGetParameterResourceIndex(parameter);
-
-					// Get the parameter resource, to calculate the physical index
-					CGresource res = cgGetParameterResource(parameter);
-					bool isRegisterCombiner = false;
-					UINT32 regCombinerPhysicalIndex = 0;
-					switch (res)
-					{
-					case CG_COMBINER_STAGE_CONST0:
-						// register combiner, const 0
-						// the index relates to the texture stage; store this as (stage * 2) + 0
-						regCombinerPhysicalIndex = logicalIndex * 2;
-						isRegisterCombiner = true;
-						break;
-					case CG_COMBINER_STAGE_CONST1:
-						// register combiner, const 1
-						// the index relates to the texture stage; store this as (stage * 2) + 1
-						regCombinerPhysicalIndex = (logicalIndex * 2) + 1;
-						isRegisterCombiner = true;
-						break;
-					default:
-						// normal constant
-						break;
-					}
-
-					// Trim the '[0]' suffix if it exists, we will add our own indexing later
-					if (StringUtil::endsWith(paramName, "[0]", false))
-					{
-						paramName.erase(paramName.size() - 3);
-					}
-
-
-					GpuConstantDefinition def;
-					def.arraySize = contextArraySize;
-					mapTypeAndElementSize(paramType, isRegisterCombiner, def);
-
-					if (def.constType == GCT_UNKNOWN)
-					{
-						gDebug().log("Problem parsing the following Cg Uniform: '" + paramName + "'", "RenderSystem");
-						// next uniform
-						parameter = cgGetNextParameter(parameter);
-						continue;
-					}
-					if (isRegisterCombiner)
-					{
-						def.physicalIndex = regCombinerPhysicalIndex;
-					}
-					else
-					{
-						// base position on existing buffer contents
-						if(def.isSampler())
-						{
-							def.physicalIndex = mSamplerLogicalToPhysical->bufferSize;
-						}
-						else
-						{
-							if (def.isFloat())
-							{
-								def.physicalIndex = mFloatLogicalToPhysical->bufferSize;
-							}
-							else
-							{
-								def.physicalIndex = mIntLogicalToPhysical->bufferSize;
-							}
-						}
-					}
-
-					def.logicalIndex = logicalIndex;
-					mConstantDefs->map.insert(GpuConstantDefinitionMap::value_type(paramName, def));
-
-					// Record logical / physical mapping
-					if(def.isSampler())
-					{
-						mSamplerLogicalToPhysical->map.insert(
-							GpuLogicalIndexUseMap::value_type(logicalIndex, 
-							GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
-						mSamplerLogicalToPhysical->bufferSize += def.arraySize;
-						mConstantDefs->samplerCount = mSamplerLogicalToPhysical->bufferSize;
-
-						mTextureLogicalToPhysical->map.insert(
-							GpuLogicalIndexUseMap::value_type(logicalIndex, 
-							GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
-						mTextureLogicalToPhysical->bufferSize += def.arraySize;
-						mConstantDefs->textureCount = mTextureLogicalToPhysical->bufferSize;
-					}
-					else
-					{
-						if (def.isFloat())
-						{
-							mFloatLogicalToPhysical->map.insert(
-								GpuLogicalIndexUseMap::value_type(logicalIndex, 
-								GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
-							mFloatLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
-							mConstantDefs->floatBufferSize = mFloatLogicalToPhysical->bufferSize;
-						}
-						else
-						{
-							mIntLogicalToPhysical->map.insert(
-								GpuLogicalIndexUseMap::value_type(logicalIndex, 
-								GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
-							mIntLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
-							mConstantDefs->intBufferSize = mIntLogicalToPhysical->bufferSize;
-						}
-					}
-
-					// Deal with array indexing
-					mConstantDefs->generateConstantDefinitionArrayEntries(paramName, def);
-
-					break;
-		
-				}
-					
-            }
-            // Get next
-            parameter = cgGetNextParameter(parameter);
-        }
+		//while (parameter != 0)
+  //      {
+  //          // Look for parameters
+  //          // Don't bother enumerating unused parameters, especially since they will
+  //          // be optimised out and therefore not in the indexed versions
+  //          CGtype paramType = cgGetParameterType(parameter);
+
+  //          if (cgGetParameterVariability(parameter) == CG_UNIFORM &&
+  //              paramType != CG_SAMPLERRECT &&
+  //              cgGetParameterDirection(parameter) != CG_OUT && 
+  //              cgIsParameterReferenced(parameter))
+  //          {
+		//		int arraySize;
+
+		//		switch(paramType)
+		//		{
+		//		case CG_STRUCT:
+		//			recurseParams(cgGetFirstStructParameter(parameter));
+		//			break;
+		//		case CG_ARRAY:
+		//			// Support only 1-dimensional arrays
+		//			arraySize = cgGetArraySize(parameter, 0);
+		//			recurseParams(cgGetArrayParameter(parameter, 0), (size_t)arraySize);
+		//			break;
+		//		default:
+		//			// Normal path (leaf)
+		//			String paramName = cgGetParameterName(parameter);
+		//			UINT32 logicalIndex = (UINT32)cgGetParameterResourceIndex(parameter);
+
+		//			// Get the parameter resource, to calculate the physical index
+		//			CGresource res = cgGetParameterResource(parameter);
+		//			bool isRegisterCombiner = false;
+		//			UINT32 regCombinerPhysicalIndex = 0;
+		//			switch (res)
+		//			{
+		//			case CG_COMBINER_STAGE_CONST0:
+		//				// register combiner, const 0
+		//				// the index relates to the texture stage; store this as (stage * 2) + 0
+		//				regCombinerPhysicalIndex = logicalIndex * 2;
+		//				isRegisterCombiner = true;
+		//				break;
+		//			case CG_COMBINER_STAGE_CONST1:
+		//				// register combiner, const 1
+		//				// the index relates to the texture stage; store this as (stage * 2) + 1
+		//				regCombinerPhysicalIndex = (logicalIndex * 2) + 1;
+		//				isRegisterCombiner = true;
+		//				break;
+		//			default:
+		//				// normal constant
+		//				break;
+		//			}
+
+		//			// Trim the '[0]' suffix if it exists, we will add our own indexing later
+		//			if (StringUtil::endsWith(paramName, "[0]", false))
+		//			{
+		//				paramName.erase(paramName.size() - 3);
+		//			}
+
+
+		//			GpuConstantDefinition def;
+		//			def.arraySize = contextArraySize;
+		//			mapTypeAndElementSize(paramType, isRegisterCombiner, def);
+
+		//			if (def.constType == GCT_UNKNOWN)
+		//			{
+		//				gDebug().log("Problem parsing the following Cg Uniform: '" + paramName + "'", "RenderSystem");
+		//				// next uniform
+		//				parameter = cgGetNextParameter(parameter);
+		//				continue;
+		//			}
+		//			if (isRegisterCombiner)
+		//			{
+		//				def.physicalIndex = regCombinerPhysicalIndex;
+		//			}
+		//			else
+		//			{
+		//				// base position on existing buffer contents
+		//				if(def.isSampler())
+		//				{
+		//					def.physicalIndex = mSamplerLogicalToPhysical->bufferSize;
+		//				}
+		//				else
+		//				{
+		//					if (def.isFloat())
+		//					{
+		//						def.physicalIndex = mFloatLogicalToPhysical->bufferSize;
+		//					}
+		//					else
+		//					{
+		//						def.physicalIndex = mIntLogicalToPhysical->bufferSize;
+		//					}
+		//				}
+		//			}
+
+		//			def.logicalIndex = logicalIndex;
+		//			mConstantDefs->map.insert(GpuConstantDefinitionMap::value_type(paramName, def));
+
+		//			// Record logical / physical mapping
+		//			if(def.isSampler())
+		//			{
+		//				mSamplerLogicalToPhysical->map.insert(
+		//					GpuLogicalIndexUseMap::value_type(logicalIndex, 
+		//					GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
+		//				mSamplerLogicalToPhysical->bufferSize += def.arraySize;
+		//				mConstantDefs->samplerCount = mSamplerLogicalToPhysical->bufferSize;
+
+		//				mTextureLogicalToPhysical->map.insert(
+		//					GpuLogicalIndexUseMap::value_type(logicalIndex, 
+		//					GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
+		//				mTextureLogicalToPhysical->bufferSize += def.arraySize;
+		//				mConstantDefs->textureCount = mTextureLogicalToPhysical->bufferSize;
+		//			}
+		//			else
+		//			{
+		//				if (def.isFloat())
+		//				{
+		//					mFloatLogicalToPhysical->map.insert(
+		//						GpuLogicalIndexUseMap::value_type(logicalIndex, 
+		//						GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
+		//					mFloatLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
+		//					mConstantDefs->floatBufferSize = mFloatLogicalToPhysical->bufferSize;
+		//				}
+		//				else
+		//				{
+		//					mIntLogicalToPhysical->map.insert(
+		//						GpuLogicalIndexUseMap::value_type(logicalIndex, 
+		//						GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
+		//					mIntLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
+		//					mConstantDefs->intBufferSize = mIntLogicalToPhysical->bufferSize;
+		//				}
+		//			}
+
+		//			// Deal with array indexing
+		//			mConstantDefs->generateConstantDefinitionArrayEntries(paramName, def);
+
+		//			break;
+		//
+		//		}
+		//			
+  //          }
+  //          // Get next
+  //          parameter = cgGetNextParameter(parameter);
+  //      }
 
         
     }

+ 1 - 31
CamelotRenderer/Source/CmGpuProgram.cpp

@@ -50,7 +50,7 @@ namespace CamelotEngine
         :mSource(source), mEntryPoint(entryPoint), mSyntaxCode(language), mType(gptype),
 		mProfile(profile), mNeedsAdjacencyInfo(isAdjacencyInfoRequired), mCompileError(false)
     {
-		createParameterMappingStructures();
+
     }
 	//----------------------------------------------------------------------------
 	GpuProgram::~GpuProgram()
@@ -102,30 +102,6 @@ namespace CamelotEngine
 		return true;
 	}
 	//---------------------------------------------------------------------
-	void GpuProgram::createParameterMappingStructures(bool recreateIfExists) const
-	{
-		createLogicalParameterMappingStructures(recreateIfExists);
-		createNamedParameterMappingStructures(recreateIfExists);
-	}
-	//---------------------------------------------------------------------
-	void GpuProgram::createLogicalParameterMappingStructures(bool recreateIfExists) const
-	{
-		if (recreateIfExists || (mFloatLogicalToPhysical == nullptr))
-			mFloatLogicalToPhysical = GpuLogicalBufferStructPtr(new GpuLogicalBufferStruct());
-		if (recreateIfExists || (mIntLogicalToPhysical == nullptr))
-			mIntLogicalToPhysical = GpuLogicalBufferStructPtr(new GpuLogicalBufferStruct());
-		if (recreateIfExists || (mSamplerLogicalToPhysical == nullptr))
-			mSamplerLogicalToPhysical = GpuLogicalBufferStructPtr(new GpuLogicalBufferStruct());
-		if(recreateIfExists || (mTextureLogicalToPhysical == nullptr))
-			mTextureLogicalToPhysical = GpuLogicalBufferStructPtr(new GpuLogicalBufferStruct());
-	}
-	//---------------------------------------------------------------------
-	void GpuProgram::createNamedParameterMappingStructures(bool recreateIfExists) const
-	{
-		if (recreateIfExists || (mConstantDefs == nullptr))
-			mConstantDefs = GpuNamedConstantsPtr(new GpuNamedConstants());
-	}
-	//---------------------------------------------------------------------
 	GpuParamsPtr GpuProgram::createParameters(void)
 	{
 		return GpuParamsPtr(new GpuParams(mParametersDesc));
@@ -137,12 +113,6 @@ namespace CamelotEngine
 
         return language;
     }
-	const GpuNamedConstants& GpuProgram::getConstantDefinitions_internal() const 
-	{ 
-		THROW_IF_NOT_RENDER_THREAD;
-
-		return *mConstantDefs.get();
-	}
 	//----------------------------------------------------------------------------- 
 	void GpuProgram::throwIfNotRenderThread() const
 	{

+ 1 - 24
CamelotRenderer/Source/CmHighLevelGpuProgram.cpp

@@ -44,7 +44,7 @@ namespace CamelotEngine
 	HighLevelGpuProgram::HighLevelGpuProgram(const String& source, const String& entryPoint, const String& language, 
 		GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
         : GpuProgram(source, entryPoint, language, gptype, profile, isAdjacencyInfoRequired), 
-        mAssemblerProgram(0), mConstantDefsBuilt(false)
+        mAssemblerProgram(0)
     {
     }
 	//---------------------------------------------------------------------------
@@ -77,8 +77,6 @@ namespace CamelotEngine
             mAssemblerProgram = nullptr;
         }
 
-		mConstantDefsBuilt = false;
-		createParameterMappingStructures(true);
 		resetCompileError();
 
 		GpuProgram::unload_internal();
@@ -88,27 +86,6 @@ namespace CamelotEngine
     {
         // superclasses will trigger unload
     }
-	//---------------------------------------------------------------------
-	const GpuNamedConstants& HighLevelGpuProgram::getConstantDefinitions_internal() const
-	{
-		THROW_IF_NOT_RENDER_THREAD;
-
-		if (!mConstantDefsBuilt)
-		{
-			buildConstantDefinitions();
-			mConstantDefsBuilt = true;
-		}
-		return *mConstantDefs.get();
-
-	}
-	//---------------------------------------------------------------------
-	void HighLevelGpuProgram::populateParameterNames(GpuProgramParametersSharedPtr params)
-	{
-		getConstantDefinitions_internal();
-		params->_setNamedConstants(mConstantDefs);
-		// also set logical / physical maps for programs which use this
-		params->_setLogicalIndexes(mFloatLogicalToPhysical, mIntLogicalToPhysical, mSamplerLogicalToPhysical, mTextureLogicalToPhysical);
-	}
 	//---------------------------------------------------------------------
 	HighLevelGpuProgramPtr HighLevelGpuProgram::create(const String& source, const String& entryPoint, 
 		const String& language, GpuProgramType gptype, GpuProgramProfile profile)

+ 35 - 31
CamelotRenderer/Source/CmMaterial.cpp

@@ -42,7 +42,6 @@ namespace CamelotEngine
 				for(UINT32 i = 0; i < mBestTechnique->getNumPasses(); i++)
 				{
 					PassPtr curPass = mBestTechnique->getPass(i);
-
 					PassParametersPtr params = PassParametersPtr(new PassParameters());
 
 					GpuProgramHandle vertProgram = curPass->getVertexProgram();
@@ -66,6 +65,27 @@ namespace CamelotEngine
 						params->mGeomParams = geomProgram->createParameters();	
 					}
 
+					GpuProgramHandle hullProgram = curPass->getHullProgram();
+					if(hullProgram)
+					{
+						hullProgram.waitUntilLoaded();
+						params->mHullParams = hullProgram->createParameters();
+					}
+
+					GpuProgramHandle domainProgram = curPass->getDomainProgram();
+					if(domainProgram)
+					{
+						domainProgram.waitUntilLoaded();
+						params->mDomainParams = domainProgram->createParameters();
+					}
+
+					GpuProgramHandle computeProgram = curPass->getComputeProgram();
+					if(computeProgram)
+					{
+						computeProgram.waitUntilLoaded();
+						params->mComputeParams = computeProgram->createParameters();	
+					}
+
 					mParameters.push_back(params);
 				}
 			}
@@ -93,22 +113,14 @@ namespace CamelotEngine
 		{
 			PassParametersPtr params = *iter;
 
-			if(params->mVertParams)
-			{
-				if(params->mVertParams->hasTexture(name))
-					params->mVertParams->setTexture(name, value);
-			}
-
-			if(params->mFragParams)
+			for(UINT32 i = 0; i < params->getNumParams(); i++)
 			{
-				if(params->mFragParams->hasTexture(name))
-					params->mFragParams->setTexture(name, value);
-			}
-
-			if(params->mGeomParams)
-			{
-				if(params->mGeomParams->hasTexture(name))
-					params->mGeomParams->setTexture(name, value);
+				GpuParamsPtr& paramPtr = params->getParamByIdx(i);
+				if(paramPtr)
+				{
+					if(paramPtr->hasTexture(name))
+						paramPtr->setTexture(name, value);
+				}
 			}
 		}
 	}
@@ -121,22 +133,14 @@ namespace CamelotEngine
 		{
 			PassParametersPtr params = *iter;
 
-			if(params->mVertParams)
+			for(UINT32 i = 0; i < params->getNumParams(); i++)
 			{
-				if(params->mVertParams->hasSamplerState(name))
-					params->mVertParams->setSamplerState(name, samplerState);
-			}
-
-			if(params->mFragParams)
-			{
-				if(params->mFragParams->hasSamplerState(name))
-					params->mFragParams->setSamplerState(name, samplerState);
-			}
-
-			if(params->mGeomParams)
-			{
-				if(params->mGeomParams->hasSamplerState(name))
-					params->mGeomParams->setSamplerState(name, samplerState);
+				GpuParamsPtr& paramPtr = params->getParamByIdx(i);
+				if(paramPtr)
+				{
+					if(paramPtr->hasSamplerState(name))
+						paramPtr->setSamplerState(name, samplerState);
+				}
 			}
 		}
 	}

+ 0 - 30
CamelotRenderer/Source/CmPass.cpp

@@ -87,36 +87,6 @@ namespace CamelotEngine
 	{
 		return mDepthStencilState;
 	}
-    //-----------------------------------------------------------------------
-	void Pass::setVertexProgram(GpuProgramHandle gpuProgram)
-	{
-		mVertexProgram = gpuProgram;
-	}
-    //-----------------------------------------------------------------------
-	void Pass::setFragmentProgram(GpuProgramHandle gpuProgram)
-	{
-		mFragmentProgram = gpuProgram;
-	}
-	//-----------------------------------------------------------------------
-	void Pass::setGeometryProgram(GpuProgramHandle gpuProgram)
-	{
-		mGeometryProgram = gpuProgram;
-	}
-	//-----------------------------------------------------------------------
-	const GpuProgramHandle& Pass::getVertexProgram(void) const
-	{
-		return mVertexProgram;
-	}
-	//-----------------------------------------------------------------------
-	const GpuProgramHandle& Pass::getFragmentProgram(void) const
-	{
-		return mFragmentProgram;
-	}
-	//-----------------------------------------------------------------------
-	const GpuProgramHandle& Pass::getGeometryProgram(void) const
-	{
-		return mGeometryProgram;
-	}
 	//----------------------------------------------------------------------
 	RTTITypeBase* Pass::getRTTIStatic()
 	{

+ 9 - 0
CamelotRenderer/TODO.txt

@@ -19,6 +19,15 @@
 /////
 -----------GpuProgramParameters/Pass/Material REFACTOR------------------------------
 
+Re-enable DX11 and GL project dependencies in CamelotClient
+Saving/loading of material params isn't completed (in MAterialRTTI)
+In D3D9HLSLProgram make:
+ mpConstTable local to localFromSource
+ Remove old parameter creation methods
+Port OpenGL and DX11 paramters system
+
+Handling of array parameters? This needs testing
+
 Material remains a simple structure you use for easily setting all and every type of parameters for every stage.
  - Each instantiation of Material creates its own unique constant buffers
   - Attempt to detect duplicates on initialization