public void Render() { using (ScopedGlContext scopedGLContext = new ScopedGlContext(WindowInfo, GraphicsContext)) { _renderer.Initialize(); SwapBuffers(); } while (IsActive) { if (IsStopped) { return; } using (ScopedGlContext scopedGLContext = new ScopedGlContext(WindowInfo, GraphicsContext)) { _ticks += _chrono.ElapsedTicks; _chrono.Restart(); if (_device.WaitFifo()) { _device.ProcessFrame(); } if (_ticks >= _ticksPerFrame) { _device.PresentFrame(SwapBuffers); _device.Statistics.RecordSystemFrameTime(); double hostFps = _device.Statistics.GetSystemFrameRate(); double gameFps = _device.Statistics.GetGameFrameRate(); string titleNameSection = string.IsNullOrWhiteSpace(_device.System.TitleName) ? string.Empty : " | " + _device.System.TitleName; string titleIdSection = string.IsNullOrWhiteSpace(_device.System.TitleIdText) ? string.Empty : " | " + _device.System.TitleIdText.ToUpper(); _newTitle = $"Ryujinx {Program.Version}{titleNameSection}{titleIdSection} | Host FPS: {hostFps:0.0} | Game FPS: {gameFps:0.0} | " + $"Game Vsync: {(_device.EnableDeviceVsync ? "On" : "Off")}"; _titleEvent = true; _device.System.SignalVsync(); _device.VsyncEvent.Set(); _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame); } } } }
public void Exit() { if (IsStopped) { return; } IsStopped = true; IsActive = false; using (ScopedGlContext scopedGLContext = new ScopedGlContext(WindowInfo, GraphicsContext)) { _device.DisposeGpu(); } WaitEvent.Set(); }