示例#1
0
        public static Technique Parse(BytecodeReader reader, BytecodeReader variableReader)
        {
            var result          = new Technique();
            var nameOffset      = variableReader.ReadUInt32();
            var annotationCount = variableReader.ReadUInt32();
            var passCount       = variableReader.ReadUInt32();

            for (int i = 0; i < annotationCount; i++)
            {
                result.Annotations.Add(Annotation.Parse(reader, variableReader));
            }
            for (int i = 0; i < passCount; i++)
            {
                result.Passes.Add(Pass.Parse(reader, variableReader));
            }
            var nameReader = reader.CopyAtOffset((int)nameOffset);

            result.Name = nameReader.TryReadString();
            return(result);
        }
        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);
        }