Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectPass"/>.
        /// </summary>
        /// <param name="renderer">The D3D10 renderer.</param>
        /// <param name="pass">The D3D10 pass.</param>
        /// <param name="map">The input layout map to share between passes that have the same effect origin.</param>
        internal D3D10EffectPass(D3D10Renderer renderer, D3D.EffectPass pass, InputLayoutMap map)
        {
            _pass     = pass;
            _renderer = renderer;

            D3D.EffectPassDescription desc = pass.Description;
            _name      = desc.Name;
            _layoutMap = map;

            //Fetch annotations
            int annoCount = desc.AnnotationCount;

            _annotations = new D3D10EffectAnnotationCollection();
            for (int i = 0; i < annoCount; i++)
            {
                D3D.EffectVariable            anno     = _pass.GetAnnotationByIndex(i);
                D3D.EffectVariableDescription annoDesc = anno.Description;
                D3D.EffectVariable            annoVar  = anno.AsString();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Object, EffectParameterType.String));
                }
                annoVar = anno.AsScalar();
                if (annoVar != null)
                {
                    //Need to find a way to get the param type...
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Scalar, EffectParameterType.Unknown));
                }
                annoVar = anno.AsMatrix();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Matrix, EffectParameterType.Single));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectPass"/>.
        /// </summary>
        /// <param name="parent">The implementation parent.</param>
        /// <param name="effect">The D3D10 effect so we can query for variables.</param>
        /// <param name="pass">The D3D10 pass.</param>
        internal D3D10EffectPass(D3D10EffectImplementation parent, D3D.Effect effect, D3D.EffectPass pass)
        {
            _pass     = pass;
            _renderer = parent.Renderer;

            D3D.EffectPassDescription desc = pass.Description;
            _name      = desc.Name;
            _layoutMap = new InputLayoutMap(_renderer, desc.Signature);

            //Fetch annotations
            int annoCount = desc.AnnotationCount;

            _annotations = new D3D10EffectAnnotationCollection();
            for (int i = 0; i < annoCount; i++)
            {
                D3D.EffectVariable            anno     = _pass.GetAnnotationByIndex(i);
                D3D.EffectVariableDescription annoDesc = anno.Description;
                D3D.EffectVariable            annoVar  = anno.AsString();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Object, EffectParameterType.String));
                    continue;
                }
                annoVar = anno.AsScalar();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Scalar, EffectParameterType.Unknown));
                    continue;
                }
                annoVar = anno.AsMatrix();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Matrix, EffectParameterType.Unknown));
                    continue;
                }
                annoVar = anno.AsVector();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Vector, EffectParameterType.Unknown));
                }
            }

            //Now to reflect the parameters and start adding them to the shader
            D3D.EffectPassShaderDescription vertexShaderDesc = pass.VertexShaderDescription;
            D3D.EffectShaderVariable        vertexShaderVar  = vertexShaderDesc.Variable;
            ParseShader(parent, effect, vertexShaderVar);
            ParseShader(parent, effect, pass.PixelShaderDescription.Variable);

            //And the standard input layout
            CreateInputLayout(vertexShaderVar, vertexShaderDesc.Index);
        }