示例#1
0
        /// <summary>
        ///   Creates the destination parameter by a given class and index.
        /// </summary>
        /// <param name="usage"> </param>
        /// <param name="index"> </param>
        protected void CreateDestinationParamter(int usage, int index)
        {
            Axiom.Graphics.GpuProgramParameters.GpuConstantType dstParamType =
                Graphics.GpuProgramParameters.GpuConstantType.Unknown;

            switch (UsedFloatCount)
            {
            case 1:
                dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float1;
                break;

            case 2:
                dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float2;
                break;

            case 3:
                dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float3;
                break;

            case 4:
                dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float4;
                break;
            }

            if (usage == (int)Operand.OpSemantic.In)
            {
                this.dstParameter = ParameterFactory.CreateInTexcoord(dstParamType, index, Parameter.ContentType.Unknown);
            }
            else
            {
                this.dstParameter = ParameterFactory.CreateOutTexcoord(dstParamType, index, Parameter.ContentType.Unknown);
            }
        }
示例#2
0
        /// <summary>
        ///   Resolve output paramteter of this function
        /// </summary>
        /// <param name="semantic"> The desired parameter semantic </param>
        /// <param name="index"> The index of the desired parameter </param>
        /// <param name="content"> The Content of the parameter </param>
        /// <param name="type"> The type of the desired parameter </param>
        /// <returns> paramter instance in case of that resolve operation succeed </returns>
        /// <remarks>
        ///   Pass -1 as index paraemter to craete a new pareamter with the desired semantic and type
        /// </remarks>
        public Parameter ResolveOutputParameter(Parameter.SemanticType semantic, int index,
                                                Parameter.ContentType content,
                                                Graphics.GpuProgramParameters.GpuConstantType type)
        {
            Parameter param = null;

            //Check if desired parameter already defined
            param = Function.GetParameterByContent(this.outputParameters, content, type);
            if (param != null)
            {
                return(param);
            }

            //case we have to create new parameter.
            if (index == -1)
            {
                index = 0;

                //find the next availabe index of the target semantic
                for (int it = 0; it < this.outputParameters.Count; it++)
                {
                    if (this.outputParameters[it].Semantic == semantic)
                    {
                        index++;
                    }
                }
            }
            else
            {
                //check if desired parameter already defined
                param = GetParameterBySemantic(this.outputParameters, semantic, index);
                if (param != null && param.Content == content)
                {
                    if (param.Type == type)
                    {
                        return(param);
                    }
                    else
                    {
                        throw new AxiomException("Cannot resolve parameter - semantic: " + semantic.ToString() +
                                                 " - index: " + index.ToString() + " due to type mimatch. Function <" +
                                                 Name + ">");
                    }
                }
            }

            //No parameter found -> create new one
            switch (semantic)
            {
            case Parameter.SemanticType.Unknown:
                break;

            case Parameter.SemanticType.Position:
                param = ParameterFactory.CreateOutPosition(index);
                break;

            case Parameter.SemanticType.BlendWeights:
            case Parameter.SemanticType.BlendIndicies:
                throw new AxiomException("Can not resolve parameter - semantic: " + semantic.ToString() +
                                         " - index: " + index.ToString() +
                                         " since support init is not implemented yet. Function <" + Name + ">");

            case Parameter.SemanticType.Normal:
                param = ParameterFactory.CreateOutNormal(index);
                break;

            case Parameter.SemanticType.Color:
                param = ParameterFactory.CreateOutColor(index);
                break;

            case Parameter.SemanticType.TextureCoordinates:
                param = ParameterFactory.CreateOutTexcoord(type, index, content);
                break;

            case Parameter.SemanticType.Binormal:
                param = ParameterFactory.CreateOutBiNormal(index);
                break;

            case Parameter.SemanticType.Tangent:
                param = ParameterFactory.CreateOutTangent(index);
                break;

            default:
                break;
            }

            if (param != null)
            {
                AddOutputParameter(param);
            }

            return(param);
        }