public static EffectGroup Parse(BytecodeReader reader, BytecodeReader groupReader, ShaderVersion version)
        {
            var result          = new EffectGroup();
            var nameOffset      = groupReader.ReadUInt32();
            var techniqueCount  = groupReader.ReadUInt32();
            var annotationCount = groupReader.ReadUInt32();

            if (nameOffset != 0)
            {
                var nameReader = reader.CopyAtOffset((int)nameOffset);
                result.Name = nameReader.ReadString();
            }
            else
            {
                result.Name = "";
            }
            for (int i = 0; i < techniqueCount; i++)
            {
                result.Techniques.Add(EffectTechnique.Parse(reader, groupReader, version));
            }
            for (int i = 0; i < annotationCount; i++)
            {
                result.Annotations.Add(EffectAnnotation.Parse(reader, groupReader, version));
            }
            return(result);
        }
Exemple #2
0
        public static EffectChunk Parse(BytecodeReader reader, uint size)
        {
            var headerReader = reader.CopyAtCurrentPosition();
            var result       = new EffectChunk();
            var header       = result.Header = EffectHeader.Parse(headerReader);
            var bodyOffset   = header.Version.MajorVersion < 5 ?
                               0x4C : 0x60;
            var footerOffset = (int)(result.Header.FooterOffset + bodyOffset);
            var bodyReader   = reader.CopyAtOffset((int)bodyOffset);
            var footerReader = reader.CopyAtOffset(footerOffset);
            var version      = header.Version;

            for (int i = 0; i < header.ConstantBuffers; i++)
            {
                result.LocalBuffers.Add(EffectBuffer.Parse(bodyReader, footerReader, version, false));
            }
            for (int i = 0; i < header.ObjectCount; i++)
            {
                result.LocalVariables.Add(EffectObjectVariable.Parse(bodyReader, footerReader, version, false));
            }
            for (int i = 0; i < header.SharedConstantBuffers; i++)
            {
                result.SharedBuffers.Add(EffectBuffer.Parse(bodyReader, footerReader, version, true));
            }
            for (int i = 0; i < header.SharedObjectCount; i++)
            {
                result.SharedVariables.Add(EffectObjectVariable.Parse(bodyReader, footerReader, version, true));
            }
            if (header.Version.MajorVersion >= 5)
            {
                for (int i = 0; i < header.InterfaceVariableCount; i++)
                {
                    result.InterfaceVariables.Add(EffectInterfaceVariable.Parse(bodyReader, footerReader, version));
                }
                for (int i = 0; i < header.GroupCount; i++)
                {
                    result.Groups.Add(EffectGroup.Parse(bodyReader, footerReader, header.Version));
                }
            }
            else
            {
                for (int i = 0; i < header.Techniques; i++)
                {
                    result.Techniques.Add(EffectTechnique.Parse(bodyReader, footerReader, header.Version));
                }
            }
            return(result);
        }