예제 #1
0
파일: Core.cs 프로젝트: UIKit0/renderdoc
        // when loading a log while replaying remotely, provide the proxy renderer that will be used
        // as well as the hostname to replay on.
        public void LoadLogfile(int proxyRenderer, string replayHost, string logFile, bool temporary)
        {
            m_LogFile = logFile;

            m_LogLoadingInProgress = true;

            if (!temporary)
            {
                m_Config.AddRecentFile(m_Config.RecentLogFiles, logFile, 10);
            }

            if (File.Exists(Core.ConfigFilename))
            {
                m_Config.Serialize(Core.ConfigFilename);
            }

            float postloadProgress = 0.0f;

            bool progressThread = true;

            // start a modal dialog to prevent the user interacting with the form while the log is loading.
            // We'll close it down when log loading finishes (whether it succeeds or fails)
            ModalPopup modal = new ModalPopup(LogLoadCallback, true);

            Thread modalThread = new Thread(new ThreadStart(() =>
            {
                modal.SetModalText(string.Format("Loading Log {0}.", m_LogFile));

                AppWindow.BeginInvoke(new Action(() =>
                {
                    modal.ShowDialog(AppWindow);
                }));
            }));

            modalThread.Start();

            // this thread continually ticks and notifies any threads of the progress, through a float
            // that is updated by the main loading code
            Thread thread = new Thread(new ThreadStart(() =>
            {
                modal.LogfileProgressBegin();

                foreach (var p in m_ProgressListeners)
                {
                    p.LogfileProgressBegin();
                }

                while (progressThread)
                {
                    Thread.Sleep(2);

                    float progress = 0.5f * m_Renderer.LoadProgress + 0.49f * postloadProgress + 0.01f;

                    modal.LogfileProgress(progress);

                    foreach (var p in m_ProgressListeners)
                    {
                        p.LogfileProgress(progress);
                    }
                }
            }));

            thread.Start();

            // this function call will block until the log is either loaded, or there's some failure
            m_Renderer.Init(proxyRenderer, replayHost, logFile);

            // if the renderer isn't running, we hit a failure case so display an error message
            if (!m_Renderer.Running)
            {
                string errmsg = "Unknown error message";
                if (m_Renderer.InitException.Data.Contains("status"))
                {
                    errmsg = ((ReplayCreateStatus)m_Renderer.InitException.Data["status"]).Str();
                }

                if (proxyRenderer >= 0)
                {
                    MessageBox.Show(String.Format("{0}\nFailed to transfer and replay on remote host {1}: {2}.\n\n" +
                                                  "Check diagnostic log in Help menu for more details.", logFile, replayHost, errmsg),
                                    "Error opening log", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(String.Format("{0}\nFailed to open logfile for replay: {1}.\n\n" +
                                                  "Check diagnostic log in Help menu for more details.", logFile, errmsg),
                                    "Error opening log", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                progressThread = false;
                thread.Join();

                m_LogLoadingInProgress = false;

                modal.LogfileProgress(-1.0f);

                foreach (var p in m_ProgressListeners)
                {
                    p.LogfileProgress(-1.0f);
                }

                return;
            }

            m_FrameID = 0;
            m_EventID = 0;

            m_FrameInfo     = null;
            m_APIProperties = null;

            // fetch initial data like drawcalls, textures and buffers
            m_Renderer.Invoke((ReplayRenderer r) =>
            {
                m_FrameInfo = r.GetFrameInfo();

                m_APIProperties = r.GetAPIProperties();

                postloadProgress = 0.2f;

                m_DrawCalls = new FetchDrawcall[m_FrameInfo.Length][];

                postloadProgress = 0.4f;

                for (int i = 0; i < m_FrameInfo.Length; i++)
                {
                    m_DrawCalls[i] = FakeProfileMarkers(i, r.GetDrawcalls((UInt32)i, false));
                }

                m_TimedDrawcalls = false;

                postloadProgress = 0.7f;

                m_Buffers = r.GetBuffers();

                postloadProgress = 0.8f;
                var texs         = new List <FetchTexture>(r.GetTextures());
                m_Textures       = texs.OrderBy(o => o.name).ToArray();

                postloadProgress = 0.9f;

                m_D3D11PipelineState = r.GetD3D11PipelineState();
                m_GLPipelineState    = r.GetGLPipelineState();
                m_PipelineState.SetStates(m_APIProperties, m_D3D11PipelineState, m_GLPipelineState);

                postloadProgress = 1.0f;
            });

            Thread.Sleep(20);

            m_LogLoaded    = true;
            progressThread = false;

            // notify all the registers log viewers that a log has been loaded
            foreach (var logviewer in m_LogViewers)
            {
                Control c = (Control)logviewer;
                if (c.InvokeRequired)
                {
                    if (!c.IsDisposed)
                    {
                        c.Invoke(new Action(() => {
                            try
                            {
                                logviewer.OnLogfileLoaded();
                            }
                            catch (Exception ex)
                            {
                                throw new AccessViolationException("Rethrown from Invoke:\n" + ex.ToString());
                            }
                        }));
                    }
                }
                else if (!c.IsDisposed)
                {
                    logviewer.OnLogfileLoaded();
                }
            }

            m_LogLoadingInProgress = false;

            modal.LogfileProgress(1.0f);

            foreach (var p in m_ProgressListeners)
            {
                p.LogfileProgress(1.0f);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if (args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if (args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            if (args.Contains("--registerVKLayer"))
            {
                Helpers.RegisterVulkanLayer();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            // clean up any update that just happened
            string updateFilesPath = Path.Combine(Path.GetTempPath(), "RenderDocUpdate");

            try
            {
                if (Directory.Exists(updateFilesPath))
                {
                    Directory.Delete(updateFilesPath, true);
                }
            }
            catch (Exception)
            {
                // ignore any exceptions from this
            }

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach (var a in args)
            {
                if (a.ToUpperInvariant() == "--TEMPFILE")
                {
                    temp = true;
                }
            }

            string remoteHost  = "";
            uint   remoteIdent = 0;

            for (int i = 0; i < args.Length; i++)
            {
                // accept --remoteaccess for backwards compatibility
                if (i + 1 < args.Length &&
                    (args[i].ToUpperInvariant() == "--REMOTEACCESS" ||
                     args[i].ToUpperInvariant() == "--TARGETCONTROL"))
                {
                    var regexp = @"^([a-zA-Z0-9_-]+:)?([0-9]+)$";

                    var match = Regex.Match(args[i + 1], regexp);

                    if (match.Success)
                    {
                        var host = match.Groups[1].Value;
                        if (host.Length > 0 && host[host.Length - 1] == ':')
                        {
                            host = host.Substring(0, host.Length - 1);
                        }
                        uint ident = 0;
                        if (uint.TryParse(match.Groups[2].Value, out ident))
                        {
                            remoteHost  = host;
                            remoteIdent = ident;
                        }
                    }
                }
            }

            List <String> pyscripts = new List <String>();

            for (int i = 0; i + 1 < args.Length; i++)
            {
                if (args[i].ToUpperInvariant() == "--PYTHON" ||
                    args[i].ToUpperInvariant() == "--PY" ||
                    args[i].ToUpperInvariant() == "--SCRIPT")
                {
                    if (File.Exists(args[i + 1]))
                    {
                        pyscripts.Add(args[i + 1]);
                    }
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]) && Path.GetExtension(args[args.Length - 1]) != ".py")
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(String.Format("Error loading config file: {1}\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename, ex.Message));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatting();

            Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");

            var core = new Core(filename, remoteHost, remoteIdent, temp, cfg);

            for (int i = 0; i < args.Length; i++)
            {
                var a = args[i];

                if (a.ToUpperInvariant() == "--UPDATEDONE")
                {
                    cfg.CheckUpdate_UpdateAvailable = false;
                    cfg.CheckUpdate_UpdateResponse  = "";

                    bool     hasOtherJSON;
                    bool     thisRegistered;
                    string[] otherJSONs;

                    bool configured = Helpers.CheckVulkanLayerRegistration(out hasOtherJSON, out thisRegistered, out otherJSONs);

                    // if nothing is configured (ie. no other JSON files), then set up our layer
                    // as part of the update process.
                    if (!configured && !hasOtherJSON && !thisRegistered)
                    {
                        Helpers.RegisterVulkanLayer();
                    }

                    Helpers.UpdateInstalledVersionNumber();
                }

                if (a.ToUpperInvariant() == "--UPDATEFAILED")
                {
                    if (i < args.Length - 1)
                    {
                        MessageBox.Show(String.Format("Error applying update: {0}", args[i + 1]), "Error updating", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Unknown error applying update", "Error updating", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            try
            {
                if (pyscripts.Count > 0)
                {
                    var engine = Python.CreateEngine();

                    List <string> searches = new List <string>(engine.GetSearchPaths());

                    searches.Add(Directory.GetCurrentDirectory());

                    string libspath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "pythonlibs.zip");

                    if (File.Exists(libspath))
                    {
                        searches.Add(libspath);
                    }

                    engine.SetSearchPaths(searches);

                    engine.Runtime.LoadAssembly(typeof(AppMain).Assembly);

                    var scope = engine.CreateScope();

                    scope.SetVariable("pyrenderdoc", core);

                    // try to import the RenderDoc namespace.
                    // This isn't equivalent to scope.ImportModule
                    try
                    {
                        engine.CreateScriptSourceFromString("import renderdoc").Execute(scope);
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        core.Renderer.SetExceptionCatching(true);
                        foreach (var script in pyscripts)
                        {
                            engine.CreateScriptSourceFromString(File.ReadAllText(script)).Execute(scope);
                        }
                        core.Renderer.SetExceptionCatching(false);
                    }
                    catch (Exception)
                    {
                        core.Renderer.SetExceptionCatching(false);

                        // IronPython throws so many exceptions, we don't want to kill the application
                        // so we just swallow Exception to cover all the bases
                    }
                }

                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #3
0
        // generally logFile == origFilename, but if the log was transferred remotely then origFilename
        // is the log locally before being copied we can present to the user in dialogs, etc.
        public void LoadLogfile(string logFile, string origFilename, bool temporary, bool local)
        {
            m_LogFile = origFilename;

            m_LogLocal = local;

            m_LogLoadingInProgress = true;

            if (File.Exists(Core.ConfigFilename))
            {
                m_Config.Serialize(Core.ConfigFilename);
            }

            float postloadProgress = 0.0f;

            bool progressThread = true;

            // start a modal dialog to prevent the user interacting with the form while the log is loading.
            // We'll close it down when log loading finishes (whether it succeeds or fails)
            ProgressPopup modal = new ProgressPopup(LogLoadCallback, true);

            Thread modalThread = Helpers.NewThread(new ThreadStart(() =>
            {
                modal.SetModalText(string.Format("Loading Log: {0}", origFilename));

                AppWindow.BeginInvoke(new Action(() =>
                {
                    modal.ShowDialog(AppWindow);
                }));
            }));

            modalThread.Start();

            // this thread continually ticks and notifies any threads of the progress, through a float
            // that is updated by the main loading code
            Thread thread = Helpers.NewThread(new ThreadStart(() =>
            {
                modal.LogfileProgressBegin();

                foreach (var p in m_ProgressListeners)
                {
                    p.LogfileProgressBegin();
                }

                while (progressThread)
                {
                    Thread.Sleep(2);

                    float progress = 0.8f * m_Renderer.LoadProgress + 0.19f * postloadProgress + 0.01f;

                    modal.LogfileProgress(progress);

                    foreach (var p in m_ProgressListeners)
                    {
                        p.LogfileProgress(progress);
                    }
                }
            }));

            thread.Start();

            // this function call will block until the log is either loaded, or there's some failure
            m_Renderer.OpenCapture(logFile);

            // if the renderer isn't running, we hit a failure case so display an error message
            if (!m_Renderer.Running)
            {
                string errmsg = m_Renderer.InitException.Status.Str();

                MessageBox.Show(String.Format("{0}\nFailed to open file for replay: {1}.\n\n" +
                                              "Check diagnostic log in Help menu for more details.", origFilename, errmsg),
                                "Error opening log", MessageBoxButtons.OK, MessageBoxIcon.Error);

                progressThread = false;
                thread.Join();

                m_LogLoadingInProgress = false;

                modal.LogfileProgress(-1.0f);

                foreach (var p in m_ProgressListeners)
                {
                    p.LogfileProgress(-1.0f);
                }

                return;
            }

            if (!temporary)
            {
                m_Config.AddRecentFile(m_Config.RecentLogFiles, origFilename, 10);

                if (File.Exists(Core.ConfigFilename))
                {
                    m_Config.Serialize(Core.ConfigFilename);
                }
            }

            m_EventID = 0;

            m_FrameInfo     = null;
            m_APIProperties = null;

            // fetch initial data like drawcalls, textures and buffers
            m_Renderer.Invoke((ReplayRenderer r) =>
            {
                m_FrameInfo = r.GetFrameInfo();

                m_APIProperties = r.GetAPIProperties();

                postloadProgress = 0.2f;

                m_DrawCalls = FakeProfileMarkers(r.GetDrawcalls());

                bool valid = HasValidMarkerColors(m_DrawCalls);

                if (!valid)
                {
                    RemoveMarkerColors(m_DrawCalls);
                }

                postloadProgress = 0.4f;

                m_Buffers = r.GetBuffers();

                postloadProgress = 0.7f;
                var texs         = new List <FetchTexture>(r.GetTextures());
                m_Textures       = texs.OrderBy(o => o.name).ToArray();

                postloadProgress = 0.9f;

                m_D3D11PipelineState  = r.GetD3D11PipelineState();
                m_D3D12PipelineState  = r.GetD3D12PipelineState();
                m_GLPipelineState     = r.GetGLPipelineState();
                m_VulkanPipelineState = r.GetVulkanPipelineState();
                m_PipelineState.SetStates(m_APIProperties, m_D3D11PipelineState, m_D3D12PipelineState, m_GLPipelineState, m_VulkanPipelineState);

                UnreadMessageCount = 0;
                AddMessages(m_FrameInfo.debugMessages);

                postloadProgress = 1.0f;
            });

            Thread.Sleep(20);

            DateTime today   = DateTime.Now;
            DateTime compare = today.AddDays(-21);

            if (compare.CompareTo(Config.DegradedLog_LastUpdate) >= 0 && m_APIProperties.degraded)
            {
                Config.DegradedLog_LastUpdate = today;

                MessageBox.Show(String.Format("{0}\nThis log opened with degraded support - " +
                                              "this could mean missing hardware support caused a fallback to software rendering.\n\n" +
                                              "This warning will not appear every time this happens, " +
                                              "check debug errors/warnings window for more details.", origFilename),
                                "Degraded support of log", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            m_LogLoaded    = true;
            progressThread = false;

            if (local)
            {
                try
                {
                    m_LogWatcher = new FileSystemWatcher(Path.GetDirectoryName(m_LogFile), Path.GetFileName(m_LogFile));
                    m_LogWatcher.EnableRaisingEvents = true;
                    m_LogWatcher.NotifyFilter        = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite;
                    m_LogWatcher.Created            += new FileSystemEventHandler(OnLogfileChanged);
                    m_LogWatcher.Changed            += new FileSystemEventHandler(OnLogfileChanged);
                    m_LogWatcher.SynchronizingObject = m_MainWindow; // callbacks on UI thread please
                }
                catch (ArgumentException)
                {
                    // likely an "invalid" directory name - FileSystemWatcher doesn't support UNC paths properly
                }
            }

            List <ILogViewerForm> logviewers = new List <ILogViewerForm>();

            logviewers.AddRange(m_LogViewers);

            // make sure we're on a consistent event before invoking log viewer forms
            FetchDrawcall draw = m_DrawCalls.Last();

            while (draw.children != null && draw.children.Length > 0)
            {
                draw = draw.children.Last();
            }

            SetEventID(logviewers.ToArray(), draw.eventID, true);

            // notify all the registers log viewers that a log has been loaded
            foreach (var logviewer in logviewers)
            {
                if (logviewer == null || !(logviewer is Control))
                {
                    continue;
                }

                Control c = (Control)logviewer;
                if (c.InvokeRequired)
                {
                    if (!c.IsDisposed)
                    {
                        c.Invoke(new Action(() => {
                            try
                            {
                                logviewer.OnLogfileLoaded();
                            }
                            catch (Exception ex)
                            {
                                throw new AccessViolationException("Rethrown from Invoke:\n" + ex.ToString());
                            }
                        }));
                    }
                }
                else if (!c.IsDisposed)
                {
                    logviewer.OnLogfileLoaded();
                }
            }

            m_LogLoadingInProgress = false;

            modal.LogfileProgress(1.0f);

            foreach (var p in m_ProgressListeners)
            {
                p.LogfileProgress(1.0f);
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if(args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if(args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            if (args.Contains("--registerVKLayer"))
            {
                Helpers.RegisterVulkanLayer();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            // clean up any update that just happened
            string updateFilesPath = Path.Combine(Path.GetTempPath(), "RenderDocUpdate");

            try
            {
                if (Directory.Exists(updateFilesPath))
                    Directory.Delete(updateFilesPath, true);
            }
            catch (Exception)
            {
                // ignore any exceptions from this
            }

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach(var a in args)
            {
                if(a.ToUpperInvariant() == "--TEMPFILE")
                    temp = true;
            }

            string remoteHost = "";
            uint remoteIdent = 0;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].ToUpperInvariant() == "--REMOTEACCESS" && i + 1 < args.Length)
                {
                    var regexp = @"^([a-zA-Z0-9_-]+:)?([0-9]+)$";

                    var match = Regex.Match(args[i+1], regexp);

                    if (match.Success)
                    {
                        var host = match.Groups[1].Value;
                        if (host.Length > 0 && host[host.Length - 1] == ':')
                            host = host.Substring(0, host.Length - 1);
                        uint ident = 0;
                        if (uint.TryParse(match.Groups[2].Value, out ident))
                        {
                            remoteHost = host;
                            remoteIdent = ident;
                        }
                    }
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(String.Format("Error loading config file: {1}\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename, ex.Message));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatting();

            Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");

            var core = new Core(filename, remoteHost, remoteIdent, temp, cfg);

            foreach (var a in args)
            {
                if (a.ToUpperInvariant() == "--UPDATEDONE")
                {
                    cfg.CheckUpdate_UpdateAvailable = false;
                    cfg.CheckUpdate_UpdateResponse = "";

                    bool hasOtherJSON;
                    bool thisRegistered;
                    string[] otherJSONs;

                    bool configured = Helpers.CheckVulkanLayerRegistration(out hasOtherJSON, out thisRegistered, out otherJSONs);

                    // if nothing is configured (ie. no other JSON files), then set up our layer
                    // as part of the update process.
                    if (!configured && !hasOtherJSON && !thisRegistered)
                    {
                        Helpers.RegisterVulkanLayer();
                    }
                }
            }

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #5
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if(args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if(args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach(var a in args)
            {
                if(a.ToLowerInvariant() == "--tempfile")
                    temp = true;
            }

            string remoteHost = "";
            uint remoteIdent = 0;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].ToLowerInvariant() == "--remoteaccess" && i + 1 < args.Length)
                {
                    var regexp = @"^([a-zA-Z0-9_-]+:)?([0-9]+)$";

                    var match = Regex.Match(args[i+1], regexp);

                    if (match.Success)
                    {
                        var host = match.Groups[1].Value;
                        if (host != "" && host[host.Length - 1] == ':')
                            host = host.Substring(0, host.Length - 1);
                        uint ident = 0;
                        if (uint.TryParse(match.Groups[2].Value, out ident))
                        {
                            remoteHost = host;
                            remoteIdent = ident;
                        }
                    }
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(String.Format("Error loading config file: {1}\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename, ex.Message));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatter();

            Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");

            var core = new Core(filename, remoteHost, remoteIdent, temp, cfg);

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #6
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if (args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if (args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            // clean up any update that just happened
            string updateFilesPath = Path.Combine(Path.GetTempPath(), "RenderDocUpdate");

            try
            {
                if (Directory.Exists(updateFilesPath))
                {
                    Directory.Delete(updateFilesPath, true);
                }
            }
            catch (Exception)
            {
                // ignore any exceptions from this
            }

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach (var a in args)
            {
                if (a.ToUpperInvariant() == "--TEMPFILE")
                {
                    temp = true;
                }
            }

            string remoteHost  = "";
            uint   remoteIdent = 0;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].ToUpperInvariant() == "--REMOTEACCESS" && i + 1 < args.Length)
                {
                    var regexp = @"^([a-zA-Z0-9_-]+:)?([0-9]+)$";

                    var match = Regex.Match(args[i + 1], regexp);

                    if (match.Success)
                    {
                        var host = match.Groups[1].Value;
                        if (host.Length > 0 && host[host.Length - 1] == ':')
                        {
                            host = host.Substring(0, host.Length - 1);
                        }
                        uint ident = 0;
                        if (uint.TryParse(match.Groups[2].Value, out ident))
                        {
                            remoteHost  = host;
                            remoteIdent = ident;
                        }
                    }
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(String.Format("Error loading config file: {1}\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename, ex.Message));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatting();

            Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");

            var core = new Core(filename, remoteHost, remoteIdent, temp, cfg);

            foreach (var a in args)
            {
                if (a.ToUpperInvariant() == "--UPDATEDONE")
                {
                    cfg.CheckUpdate_UpdateAvailable = false;
                    cfg.CheckUpdate_UpdateResponse  = "";
                }
            }

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #7
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if (args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if (args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach (var a in args)
            {
                if (a.ToLowerInvariant() == "--tempfile")
                {
                    temp = true;
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatter();

            var core = new Core(filename, temp, cfg);

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #8
0
파일: AppMain.cs 프로젝트: n1nj4n/renderdoc
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if(args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if(args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach(var a in args)
            {
                if(a.ToLowerInvariant() == "--tempfile")
                    temp = true;
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatter();

            var core = new Core(filename, temp, cfg);

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }