Ejemplo n.º 1
0
        public static EffectContainer Parse(BytecodeReader reader, uint length)
        {
            var result         = new EffectContainer();
            var chunkReader    = reader.CopyAtCurrentPosition();
            var footerOffset   = chunkReader.ReadUInt32() + 4;
            var bodyReader     = chunkReader.CopyAtCurrentPosition();
            var footerReader   = reader.CopyAtOffset((int)footerOffset);
            var variableCount  = footerReader.ReadUInt32();
            var techniqueCount = footerReader.ReadUInt32();
            var passCount      = footerReader.ReadUInt32();
            var shaderCount    = footerReader.ReadUInt32();

            for (int i = 0; i < variableCount; i++)
            {
                result.Variables.Add(Variable.Parse(bodyReader, footerReader));
            }
            for (int i = 0; i < techniqueCount; i++)
            {
                result.Techniques.Add(Technique.Parse(bodyReader, footerReader));
            }
            var variableBlobCount = footerReader.ReadUInt32();
            var stateBlobCount    = footerReader.ReadUInt32();

            for (int i = 0; i < variableBlobCount; i++)
            {
                var data = VariableBlob.Parse(bodyReader, footerReader);
                result.VariableBlobs.Add(data);
            }
            for (int i = 0; i < stateBlobCount; i++)
            {
                var data = StateBlob.Parse(bodyReader, footerReader);
                result.StateBlobs.Add(data);
            }
            result.BuildBlobLookup();
            return(result);
        }