internal static EffectInterfaceVariable Parse(BytecodeReader reader, BytecodeReader variableReader, ShaderVersion version) { var result = new EffectInterfaceVariable(); var nameOffset = variableReader.ReadUInt32(); var nameReader = reader.CopyAtOffset((int)nameOffset); result.Name = nameReader.ReadString(); var typeOffset = variableReader.ReadUInt32(); var typeReader = reader.CopyAtOffset((int)typeOffset); result.Type = EffectType.Parse(reader, typeReader, version); //Pointer to InterfaceInitializer var defaultValueOffset = variableReader.ReadUInt32(); var initializerReader = reader.CopyAtOffset((int)defaultValueOffset); var instanceNameOffset = initializerReader.ReadUInt32(); var instanceNameReader = reader.CopyAtOffset((int)instanceNameOffset); result.InstanceName = instanceNameReader.ReadString(); result.Flags = variableReader.ReadUInt32(); var annotationCount = variableReader.ReadUInt32(); for (int i = 0; i < annotationCount; i++) { result.Annotations.Add(EffectAnnotation.Parse(reader, variableReader, version)); } return(result); }
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); }