Exemplo n.º 1
0
        public override void Export(ShaderWriter writer, ref ShaderSubProgram subProgram)
        {
            byte[] exportData       = subProgram.ProgramData;
            int    dataOffset       = DXShaderProgramRestorer.GetDataOffset(writer.Version, m_graphicApi, subProgram);
            int    dataLength       = exportData.Length - dataOffset;
            IntPtr unmanagedPointer = Marshal.AllocHGlobal(dataLength);

            Marshal.Copy(exportData, dataOffset, unmanagedPointer, dataLength);

            D3DCompiler.D3DCompiler.D3DDisassemble(unmanagedPointer, (uint)dataLength, 0, null, out IDxcBlob disassembly);
            string disassemblyText = GetStringFromBlob(disassembly);

            ExportListing(writer, disassemblyText);

            Marshal.FreeHGlobal(unmanagedPointer);
        }
Exemplo n.º 2
0
        public override void DoExport(string filePath, uTinyRipper.Version version, ref ShaderSubProgram subProgram)
        {
            byte[] exportData       = subProgram.ProgramData;
            int    dataOffset       = DXShaderProgramRestorer.GetDataOffset(version, m_graphicApi, subProgram);
            int    dataLength       = exportData.Length - dataOffset;
            IntPtr unmanagedPointer = Marshal.AllocHGlobal(dataLength);

            Marshal.Copy(exportData, dataOffset, unmanagedPointer, dataLength);

            var parameters = new object[] { unmanagedPointer, (uint)dataLength, (uint)0, null, null };

            dissassembleMethod.Invoke(null, parameters);
            IDxcBlob disassembly     = (IDxcBlob)parameters[4];
            string   disassemblyText = GetStringFromBlob(disassembly);

            File.WriteAllText(filePath, disassemblyText);
            Marshal.FreeHGlobal(unmanagedPointer);
        }