当前位置: 首页>>代码示例>>C#>>正文


C# GpuProgramParameters.MapParamNameToIndex方法代码示例

本文整理汇总了C#中Axiom.Graphics.GpuProgramParameters.MapParamNameToIndex方法的典型用法代码示例。如果您正苦于以下问题:C# GpuProgramParameters.MapParamNameToIndex方法的具体用法?C# GpuProgramParameters.MapParamNameToIndex怎么用?C# GpuProgramParameters.MapParamNameToIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Axiom.Graphics.GpuProgramParameters的用法示例。


在下文中一共展示了GpuProgramParameters.MapParamNameToIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Clone

		public GpuProgramParameters Clone()
		{
			GpuProgramParameters p = new GpuProgramParameters();

			// copy int constants
			for ( int i = 0; i < intConstants.Count; i++ )
			{
				IntConstantEntry e = intConstants[ i ] as IntConstantEntry;
				if ( e.isSet )
				{
					p.SetConstant( i, e.val );
				}
			}

			// copy float constants
			for ( int i = 0; i < floatConstants.Count; i++ )
			{
				FloatConstantEntry e = floatConstants[ i ] as FloatConstantEntry;
				if ( e.isSet )
				{
					p.SetConstant( i, e.val );
				}
			}

			// copy auto constants
			for ( int i = 0; i < autoConstantList.Count; i++ )
			{
				AutoConstantEntry entry = autoConstantList[ i ] as AutoConstantEntry;
				p.SetAutoConstant( entry.Clone() );
			}

			// copy named params
			foreach ( string key in namedParams.Keys )
			{
				p.MapParamNameToIndex( key, namedParams[ key ] );
			}

			for ( int i = 0; i < paramTypeList.Count; i++ )
			{
			}
			foreach ( ParameterEntry pEntry in paramTypeList )
			{
				p.AddParameterToDefaultsList( pEntry.ParameterType, pEntry.ParameterName );
			}

			// copy value members
			p.transposeMatrices = transposeMatrices;
			p.autoAddParamName = autoAddParamName;

			return p;
		}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:51,代码来源:GpuProgramParameters.cs

示例2: ProcessParamElement

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="prefix"></param>
        /// <param name="index"></param>
        /// <param name="parms"></param>
        protected void ProcessParamElement(D3D.EffectHandle parent, string prefix, int index, GpuProgramParameters parms)
        {
            D3D.EffectHandle constant = constantTable.GetConstant(parent, index);

            // Since D3D HLSL doesn't deal with naming of array and struct parameters
            // automatically, we have to do it by hand
            D3D.ConstantDescription[] descs = constantTable.GetConstantDescription(constant, 1);
            D3D.ConstantDescription desc = descs[0];

            string paramName = desc.Name;

            // trim the odd '$' which appears at the start of the names in HLSL
            if(paramName.StartsWith("$")) {
                paramName = paramName.Remove(0, 1);
            }

            // If it's an array, elements will be > 1
            for(int e = 0; e < desc.Elements; e++) {
                if(desc.Class == ParameterClass.Struct) {
                    // work out a new prefix for the nextest members
                    // if its an array, we need the index
                    if(desc.Elements > 1) {
                        prefix += string.Format("{0}[{1}].", paramName, e);
                    }
                    else {
                        prefix += ".";
                    }

                    // cascade into the struct members
                    for(int i = 0; i < desc.StructMembers; i++) {
                        ProcessParamElement(constant, prefix, i, parms);
                    }
                }
                else {
                    // process params
                    if(desc.ParameterType == ParameterType.Float ||
                        desc.ParameterType == ParameterType.Integer ||
                        desc.ParameterType == ParameterType.Boolean) {

                        int paramIndex = desc.RegisterIndex;
                        string newName = prefix + paramName;

                        // if this is an array, we need to appent the element index
                        if(desc.Elements > 1) {
                            newName += string.Format("[{0}]", e);
                        }

                        // map the named param to the index
                        parms.MapParamNameToIndex(newName, paramIndex+e);
                    }
                }
            }
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:60,代码来源:HLSLProgram.cs

示例3: PopulateParameterNames

		/// <summary>
		///
		/// </summary>
		/// <param name="parms"></param>
		protected override void PopulateParameterNames( GpuProgramParameters parms )
		{
			Debug.Assert( cgProgram != IntPtr.Zero );

			// Note use of 'leaf' format so we only get bottom-level params, not structs
			IntPtr param = Cg.cgGetFirstLeafParameter( cgProgram, Cg.CG_PROGRAM );

			int index = 0;

			// loop through the rest of the params
			while ( param != IntPtr.Zero )
			{

				// get the type of this param up front
				int paramType = Cg.cgGetParameterType( param );

				// Look for uniform parameters only
				// Don't bother enumerating unused parameters, especially since they will
				// be optimized out and therefore not in the indexed versions
				if ( Cg.cgIsParameterReferenced( param ) != 0
					&& Cg.cgGetParameterVariability( param ) == Cg.CG_UNIFORM
					&& Cg.cgGetParameterDirection( param ) != Cg.CG_OUT
					&& paramType != Cg.CG_SAMPLER1D
					&& paramType != Cg.CG_SAMPLER2D
					&& paramType != Cg.CG_SAMPLER3D
					&& paramType != Cg.CG_SAMPLERCUBE
					&& paramType != Cg.CG_SAMPLERRECT )
				{

					// get the name and index of the program param
					string name = Cg.cgGetParameterName( param );

					// fp30 uses named rather than indexed params, so Cg returns
					// 0 for the index. However, we need the index to be unique here
					// Resource type 3256 doesn't have a define in the Cg header, so I assume
					// it means an unused or non-indexed params, since it is also returned
					// for programs that have a param that is not referenced in the program
					// and ends up getting pruned by the Cg compiler
					if ( selectedCgProfile == Cg.CG_PROFILE_FP30 )
					{
						// use a fake index just to order the named fp30 params
						index++;
					}
					else
					{
						// get the param constant index the normal way
						index = Cg.cgGetParameterResourceIndex( param );
					}

					// get the underlying resource type of this param
					// we need a special case for the register combiner
					// stage constants.
					int resource = Cg.cgGetParameterResource( param );

					// Get the parameter resource, so we know what type we're dealing with
					switch ( resource )
					{
						case Cg.CG_COMBINER_STAGE_CONST0:
							// register combiner, const 0
							// the index relates to the texture stage; store this as (stage * 2) + 0
							index = index * 2;
							break;

						case Cg.CG_COMBINER_STAGE_CONST1:
							// register combiner, const 1
							// the index relates to the texture stage; store this as (stage * 2) + 1
							index = ( index * 2 ) + 1;
							break;
					}

					// map the param to the index
					parms.MapParamNameToIndex( name, index );
				}

				// get the next param
				param = Cg.cgGetNextLeafParameter( param );
			}
		}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:82,代码来源:CgProgram.cs

示例4: Clone

        public GpuProgramParameters Clone()
        {
            GpuProgramParameters p = new GpuProgramParameters();

            // copy int constants
            for ( int i = 0; i < intConstants.Count; i++ )
            {
                IntConstantEntry e = intConstants[i];
                if ( e.isSet )
                {
                    p.SetConstant(i, e.val);
                }
            }

            // copy float constants
            p.floatConstantsArray = new float[floatConstantsArray.Length];
            Array.Copy(floatConstantsArray, p.floatConstantsArray, floatConstantsArray.Length);
            p.floatIsSet = new bool[floatIsSet.Length];
            Array.Copy(floatIsSet, p.floatIsSet, floatIsSet.Length);
            p.float4VecConstantsCount = float4VecConstantsCount;
            p.maxSetCount = maxSetCount;

            // copy auto constants
            for(int i = 0; i < autoConstantList.Count; i++)
            {
                AutoConstantEntry entry = autoConstantList[i];
                p.SetAutoConstant(entry.Clone());
            }

            // copy named params
            foreach ( DictionaryEntry e in namedParams )
            {
                p.MapParamNameToIndex(e.Key as string, (int)e.Value);
            }

            for ( int i = 0; i < paramTypeList.Count; i++ )
            {

            }
            foreach ( ParameterEntry pEntry in paramTypeList )
            {
                p.AddParameterToDefaultsList(pEntry.ParameterType, pEntry.ParameterName);
            }

            // copy value members
            p.transposeMatrices = transposeMatrices;
            p.autoAddParamName = autoAddParamName;

            return p;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:50,代码来源:GpuProgramParameters.cs


注:本文中的Axiom.Graphics.GpuProgramParameters.MapParamNameToIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。