Esempio n. 1
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);
        }
        public static EffectTechnique Parse(BytecodeReader reader, BytecodeReader techniqueReader, ShaderVersion version)
        {
            var result     = new EffectTechnique(version);
            var nameOffset = techniqueReader.ReadUInt32();
            var nameReader = reader.CopyAtOffset((int)nameOffset);

            result.Name = nameReader.ReadString();
            var passCount       = techniqueReader.ReadUInt32();
            var annotationCount = techniqueReader.ReadUInt32();

            for (int i = 0; i < annotationCount; i++)
            {
                result.Annotations.Add(EffectAnnotation.Parse(reader, techniqueReader, version));
            }
            for (int i = 0; i < passCount; i++)
            {
                result.Passes.Add(EffectPass.Parse(reader, techniqueReader, version));
            }
            return(result);
        }
Esempio n. 3
0
        private static void CompareTechniques(EffectTechnique reflectionTechnique, Fx10.EffectTechnique technique)
        {
            EffectTechniqueDescription desc = reflectionTechnique.Description;

            Assert.AreEqual(desc.Name, technique.Name);
            Assert.AreEqual(desc.AnnotationCount, technique.Annotations.Count);
            Assert.AreEqual(desc.PassCount, technique.Passes.Count);
            var passes = reflectionTechnique.GetPasses();

            for (int i = 0; i < desc.PassCount; i++)
            {
                ComparePass(passes[i], technique.Passes[i]);
            }
            var annotations = reflectionTechnique.GetAnnotations();

            for (int i = 0; i < desc.AnnotationCount; i++)
            {
                CompareVariable(annotations[i], technique.Annotations[i]);
            }
        }