Exemplo n.º 1
0
 private void ExportSnippet(TextWriter writer, Stream stream, int offset, int size)
 {
     using (PartialStream snippetStream = new PartialStream(stream, offset, size))
     {
         int decodedSize = SmolvDecoder.GetDecodedBufferSize(snippetStream);
         if (decodedSize == 0)
         {
             throw new Exception("Invalid SMOL-V shader header");
         }
         using (MemoryStream decodedStream = new MemoryStream(new byte[decodedSize]))
         {
             if (SmolvDecoder.Decode(stream, size, decodedStream))
             {
                 decodedStream.Position = 0;
                 Module module  = Module.ReadFrom(decodedStream);
                 string listing = m_disassembler.Disassemble(module, DisassemblyOptions.Default);
                 ExportListing(writer, listing);
             }
             else
             {
                 throw new Exception("Unable to decode SMOL-V shader");
             }
         }
     }
 }
Exemplo n.º 2
0
        private static string ExportSnippet(Stream stream, int offset, int size)
        {
            stream.Position = offset;
            var decodedSize = SmolvDecoder.GetDecodedBufferSize(stream);

            if (decodedSize == 0)
            {
                throw new Exception("Invalid SMOL-V shader header");
            }
            using (var decodedStream = new MemoryStream(new byte[decodedSize]))
            {
                if (SmolvDecoder.Decode(stream, size, decodedStream))
                {
                    decodedStream.Position = 0;
                    var module       = Module.ReadFrom(decodedStream);
                    var disassembler = new Disassembler();
                    return(disassembler.Disassemble(module, DisassemblyOptions.Default).Replace("\r\n", "\n"));
                }
                else
                {
                    throw new Exception("Unable to decode SMOL-V shader");
                }
            }
        }