public static Sfi0Chunk Parse(BytecodeReader reader) { var flags = reader.ReadInt32(); Debug.Assert(flags == 1 || flags == 2); // TODO: Unknown var result = new Sfi0Chunk(); if (flags == 1) result.RequiresDoublePrecisionFloatingPoint = true; return result; }
///// <summary> ///// Gets the corresponding interface slot for a variable that represents an interface pointer. ///// </summary> //public List<uint> InterfaceSlots { get; private set; } public static ShaderVariable Parse(BytecodeReader reader, BytecodeReader variableReader, ShaderVersion target, bool isFirst) { uint nameOffset = variableReader.ReadUInt32(); var nameReader = reader.CopyAtOffset((int) nameOffset); var startOffset = variableReader.ReadUInt32(); uint size = variableReader.ReadUInt32(); var flags = (ShaderVariableFlags) variableReader.ReadUInt32(); var typeOffset = variableReader.ReadUInt32(); var typeReader = reader.CopyAtOffset((int) typeOffset); var shaderType = ShaderType.Parse(reader, typeReader, target, 2, isFirst, startOffset); var defaultValueOffset = variableReader.ReadUInt32(); List<Number> defaultValue = null; if (defaultValueOffset != 0) { defaultValue = new List<Number>(); var defaultValueReader = reader.CopyAtOffset((int) defaultValueOffset); if (size % 4 != 0) throw new ParseException("Can only deal with 4-byte default values at the moment."); for (int i = 0; i < size; i += 4) defaultValue.Add(new Number(defaultValueReader.ReadBytes(4))); } var name = nameReader.ReadString(); var result = new ShaderVariable { DefaultValue = defaultValue, Member = new ShaderTypeMember(0) { Name = name, Offset = startOffset, Type = shaderType }, BaseType = name, Size = size, Flags = flags }; if (target.MajorVersion >= 5) { result.StartTexture = variableReader.ReadInt32(); result.TextureSize = variableReader.ReadInt32(); result.StartSampler = variableReader.ReadInt32(); result.SamplerSize = variableReader.ReadInt32(); } return result; }