public override void DoExport(string filePath, uTinyRipper.Version version, ref ShaderSubProgram subProgram) { byte[] exportData = subProgram.ProgramData; int dataOffset = 0; if (DXDataHeader.HasHeader(m_graphicApi)) { dataOffset = DXDataHeader.GetDataOffset(version, m_graphicApi); uint fourCC = BitConverter.ToUInt32(exportData, dataOffset); if (fourCC != DXBCFourCC) { throw new Exception("Magic number doesn't match"); } } 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); }
private static bool IsUseUnityCrunch(Version version, TextureFormat format) { if (version.IsGreaterEqual(2017, 3)) { return(true); } return(format == TextureFormat.ETC_RGB4Crunched || format == TextureFormat.ETC2_RGBA8Crunched); }
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); }
public override void DoExport(string filePath, uTinyRipper.Version version, ref ShaderSubProgram subProgram) { /*byte[] exportData = DXShaderProgramRestorer.RestoreProgramData(version, m_graphicApi, subProgram); * WrappedGlExtensions ext = new WrappedGlExtensions(); * ext.ARB_explicit_attrib_location = 1; * ext.ARB_explicit_uniform_location = 1; * ext.ARB_shading_language_420pack = 0; * ext.OVR_multiview = 0; * ext.EXT_shader_framebuffer_fetch = 0; * Shader shader = Shader.TranslateFromMem(exportData, m_GLLang, ext); * if (shader.OK == 0) * { * throw new Exception($"Error {shader.OK}"); * } * else * { * File.WriteAllText(filePath, shader.Text); * }*/ }
private static bool IsOffset5(Version version) { return(version.IsEqual(5, 3)); }
public ShaderDXExporter(Version version, ShaderGpuProgramType programType) { m_version = version; m_programType = programType; }
public ShaderDXExporter(Version version, GPUPlatform graphicApi) { m_version = version; m_graphicApi = graphicApi; }