예제 #1
0
        private SpirVModuleHeader ReadModuleHeader(WordReader reader)
        {
            int magicNumber = reader.ReadWord().Value;
            if (magicNumber != MagicNumber)
            {
                throw new ArgumentException("invalid shader program");
            }
            int version = reader.ReadWord().Value;
            int generatorIdentifier = reader.ReadWord().Value;
            int boundIds = reader.ReadWord().Value;
            int schema = reader.ReadWord().Value;

            logger.Debug("Magic Number = {0:X}\nVersion = {1}\nGenerator Identifier={2}\nids = {3}\nschema= {4}\n",
                magicNumber, version, generatorIdentifier, boundIds, schema);

            return new SpirVModuleHeader(magicNumber, version, generatorIdentifier, boundIds, schema);
        }
예제 #2
0
 public SpirVModule Load(String fileName)
 {
     using(Stream fileStream = File.Open(fileName, FileMode.Open))
     using(WordReader reader = new WordReader(fileStream))
     {
         SpirVModuleHeader header = ReadModuleHeader(reader);
         var instructionIterator = new InstructionIterator(reader);
         List<Instruction> instructions = new List<Instruction>();
         Instruction instruction = instructionIterator.Next();
         while (instruction != null)
         {
             logger.Debug("{0}", instruction);
             instructions.Add(instruction);
             instruction = instructionIterator.Next();
         }
         return new SpirVModule(header, instructions);
     }
 }
		internal InstructionIterator(WordReader reader)
		{
			this.reader = reader;
		}