Пример #1
0
        void ExtractConstantsRegisters(Stream stream, bool isForPixelShader, Dictionary <string, SilverlightEffectInternalParameter> tempParameters)
        {
            using (var reader = new BinaryReader(stream))
            {
                var version       = reader.ReadUInt32();
                var creator       = reader.ReadString();
                var constantCount = reader.ReadUInt32();

                for (var i = 0; i < constantCount; ++i)
                {
                    var descCount = reader.ReadUInt32();
                    if (descCount != 1)
                    {
                        throw new NotSupportedException();
                    }

                    var name = reader.ReadString();
                    SilverlightEffectInternalParameter effectParameter;
                    if (tempParameters.ContainsKey(name))
                    {
                        effectParameter = tempParameters[name];
                    }
                    else
                    {
                        effectParameter = new SilverlightEffectInternalParameter(device, name);
                        tempParameters.Add(name, effectParameter);
                    }

                    effectParameter.RegisterSet  = (EffectRegisterSet)reader.ReadInt32();
                    effectParameter.SamplerIndex = reader.ReadInt32();

                    if (isForPixelShader)
                    {
                        effectParameter.PixelShaderRegisterIndex = reader.ReadInt32();
                    }
                    else
                    {
                        effectParameter.VertexShaderRegisterIndex = reader.ReadInt32();
                    }

                    effectParameter.RegisterCount  = Math.Max(effectParameter.RegisterCount, reader.ReadInt32());
                    effectParameter.ParameterClass = (EffectParameterClass)reader.ReadUInt32();
                    effectParameter.ParameterType  = (EffectParameterType)reader.ReadUInt32();
                }
            }
        }
        void ExtractConstantsRegisters(Stream stream, bool isForPixelShader, Dictionary <string, SilverlightEffectInternalParameter> tempParameters)
        {
            XmlReader xmlReader = XmlReader.Create(stream);

            while (xmlReader.ReadToFollowing("Constant"))
            {
                xmlReader.ReadToDescendant("Name");
                string name = xmlReader.ReadElementContentAsString();

                SilverlightEffectInternalParameter effectParameter;
                if (tempParameters.ContainsKey(name))
                {
                    effectParameter = tempParameters[name];
                }
                else
                {
                    effectParameter = new SilverlightEffectInternalParameter(device, name);
                    tempParameters.Add(name, effectParameter);
                }

                xmlReader.ReadToNextSibling("RegisterIndex");
                int index = xmlReader.ReadElementContentAsInt();

                if (isForPixelShader)
                {
                    effectParameter.PixelShaderRegisterIndex = index;
                }
                else
                {
                    effectParameter.VertexShaderRegisterIndex = index;
                }

                xmlReader.ReadToNextSibling("RegisterCount");
                effectParameter.RegisterCount = Math.Max(effectParameter.RegisterCount, xmlReader.ReadElementContentAsInt());
            }

            xmlReader.Close();
        }
Пример #3
0
 /// <summary>Creates a new effect parameter</summary>
 internal EffectParameter(SilverlightEffectInternalParameter parameter)
 {
     internalParameter = parameter;
 }
        void ExtractConstantsRegisters(Stream stream, bool isForPixelShader, Dictionary<string, SilverlightEffectInternalParameter> tempParameters)
        {
            XmlReader xmlReader = XmlReader.Create(stream);

            while (xmlReader.ReadToFollowing("Constant"))
            {
                xmlReader.ReadToDescendant("Name");
                string name = xmlReader.ReadElementContentAsString();

                SilverlightEffectInternalParameter effectParameter;
                if (tempParameters.ContainsKey(name))
                {
                    effectParameter = tempParameters[name];
                }
                else
                {
                    effectParameter = new SilverlightEffectInternalParameter(device, name);
                    tempParameters.Add(name, effectParameter);
                }

                xmlReader.ReadToNextSibling("RegisterIndex");
                int index = xmlReader.ReadElementContentAsInt();

                if (isForPixelShader)
                    effectParameter.PixelShaderRegisterIndex = index;
                else
                    effectParameter.VertexShaderRegisterIndex = index;

                xmlReader.ReadToNextSibling("RegisterCount");
                effectParameter.RegisterCount = Math.Max(effectParameter.RegisterCount, xmlReader.ReadElementContentAsInt());
            }

            xmlReader.Close();
        }