예제 #1
0
        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);
        }
예제 #2
0
        virtual public ShaderModel ReadShader()
        {
            // Version token
            byte       minorVersion = ReadByte();
            byte       majorVersion = ReadByte();
            ShaderType shaderType   = (ShaderType)ReadUInt16();

            var shader = new ShaderModel(majorVersion, minorVersion, shaderType);

            while (true)
            {
                D3D9Instruction instruction = ReadInstruction();
                InstructionVerifier.Verify(instruction);
                shader.Instructions.Add(instruction);
                if (instruction.Opcode == Opcode.End)
                {
                    break;
                }
            }

            return(shader);
        }
예제 #3
0
 public AsmWriter(ShaderModel shader)
 {
     this.shader = shader;
 }