virtual public ShaderModel ReadShader() { int dxbc = ReadInt32(); System.Diagnostics.Debug.Assert(dxbc == FourCC.Make("DXBC")); ReadBytes(16); // checksum ReadInt32(); // 1 ReadInt32(); // totalSize int chunkCount = ReadInt32(); int[] chunkOffsets = new int[chunkCount]; for (int i = 0; i < chunkCount; i++) { chunkOffsets[i] = ReadInt32(); } ShaderModel shader = null; foreach (int chunkOffset in chunkOffsets) { BaseStream.Position = chunkOffset; string chunkType = FourCC.Decode(ReadInt32()); if (chunkType == "RDEF") { ReadBytes(20); byte majorVersion = ReadByte(); byte minorVersion = ReadByte(); ShaderType shaderType = (ShaderType)ReadUInt16(); shader = new ShaderModel(minorVersion, majorVersion, shaderType); } else if (chunkType == "OSGN") { } else if (chunkType == "SHDR") { ReadBytes(8); int chunkSize = ReadInt32() * 4; long chunkEnd = BaseStream.Position + chunkSize - 8; while (BaseStream.Position < chunkEnd) { D3D10Instruction instruction = ReadInstruction(); InstructionVerifier.Verify(instruction); shader.Instructions.Add(instruction); } } } return(shader); }
public void ReadFileHeader() { int signature = ReadInt32(); if (signature != FourCC.Make("rgxa")) { Console.WriteLine("Error: unknown file format!"); throw new InvalidDataException(); } numShaders = ReadByte(); location = Location.VertexShaders; }
private byte[] GetConstantTableData() { int ctabToken = FourCC.Make("CTAB"); var ctabComment = Instructions .OfType <D3D9Instruction>() .FirstOrDefault(x => x.Opcode == Opcode.Comment && x.Params[0] == ctabToken); if (ctabComment == null) { return(null); } byte[] constantTable = new byte[ctabComment.Params.Count * 4]; for (int i = 1; i < ctabComment.Params.Count; i++) { constantTable[i * 4 - 4] = (byte)(ctabComment.Params[i] & 0xFF); constantTable[i * 4 - 3] = (byte)((ctabComment.Params[i] >> 8) & 0xFF); constantTable[i * 4 - 2] = (byte)((ctabComment.Params[i] >> 16) & 0xFF); constantTable[i * 4 - 1] = (byte)((ctabComment.Params[i] >> 24) & 0xFF); } return(constantTable); }