Exemple #1
0
		public static ClassType Parse(BytecodeReader reader, BytecodeReader classTypeReader)
		{
			var nameOffset = classTypeReader.ReadUInt32();
			var nameReader = reader.CopyAtOffset((int) nameOffset);

			return new ClassType
			{
				Name = nameReader.ReadString(),
				ID = classTypeReader.ReadUInt16(),
				ConstantBufferStride = classTypeReader.ReadUInt16(),
				Texture = classTypeReader.ReadUInt16(),
				Sampler = classTypeReader.ReadUInt16()
			};
		}
		public static ClassInstance Parse(BytecodeReader reader, BytecodeReader classInstanceReader)
		{
			var nameOffset = classInstanceReader.ReadUInt32();
			var nameReader = reader.CopyAtOffset((int) nameOffset);
			var name = nameReader.ReadString();

			var type = classInstanceReader.ReadUInt16();
			var unknown = classInstanceReader.ReadUInt16();
			Debug.Assert(unknown == 1); // Unknown, perhaps the class instance type?

			return new ClassInstance
			{
				Name = name,
				Type = type,
				ConstantBuffer = classInstanceReader.ReadUInt16(),
				ConstantBufferOffset = classInstanceReader.ReadUInt16(),
				Texture = classInstanceReader.ReadUInt16(),
				Sampler = classInstanceReader.ReadUInt16()
			};
		}
Exemple #3
0
		public static ShaderType Parse(BytecodeReader reader, BytecodeReader typeReader, ShaderVersion target,
			int indent, bool isFirst, uint parentOffset)
		{
			var result = new ShaderType(indent, isFirst)
			{
				VariableClass = (ShaderVariableClass) typeReader.ReadUInt16(),
				VariableType = (ShaderVariableType) typeReader.ReadUInt16(),
				Rows = typeReader.ReadUInt16(),
				Columns = typeReader.ReadUInt16(),
				ElementCount = typeReader.ReadUInt16()
			};

			var memberCount = typeReader.ReadUInt16();
			var memberOffset = typeReader.ReadUInt32();

			if (target.MajorVersion >= 5)
			{
				var parentTypeOffset = typeReader.ReadUInt32(); // Guessing
				if (parentTypeOffset != 0)
				{
					var parentTypeReader = reader.CopyAtOffset((int) parentTypeOffset);
					var parentTypeClass = (ShaderVariableClass) parentTypeReader.ReadUInt16();
					Debug.Assert(parentTypeClass == ShaderVariableClass.Vector || parentTypeClass == ShaderVariableClass.InterfaceClass);

					var unknown1 = parentTypeReader.ReadUInt16();
					Debug.Assert(unknown1 == 0);
				}

				var unknown2 = typeReader.ReadUInt32();
				if (unknown2 != 0)
				{
					var unknownReader = reader.CopyAtOffset((int) unknown2);
					uint unknown3 = unknownReader.ReadUInt32();
					Debug.Assert(unknown3 == 0 || unknown3 == 5);
				}

				var unknown4 = typeReader.ReadUInt32();
				Debug.Assert(unknown4 == 0 || unknown4 == 1);

				var unknown5 = typeReader.ReadUInt32();
				if (unknown5 != 0)
				{
					var unknownReader = reader.CopyAtOffset((int) unknown5);
					var unknown6 = unknownReader.ReadUInt32();
					Debug.Assert(unknown6 == 580 || unknown6 == 740);
				}

				var parentNameOffset = typeReader.ReadUInt32();
				if (parentNameOffset > 0)
				{
					var parentNameReader = reader.CopyAtOffset((int) parentNameOffset);
					result.BaseTypeName = parentNameReader.ReadString();
				}
			}

			if (memberCount > 0)
			{
				var memberReader = reader.CopyAtOffset((int) memberOffset);
				for (int i = 0; i < memberCount; i++)
					result.Members.Add(ShaderTypeMember.Parse(reader, memberReader, target, indent + 4, i == 0,
						parentOffset));
			}

			return result;
		}