Пример #1
0
        public void Render()
        {
            InitializeRenderer();

            Device.Gpu.Renderer.Initialize(_glLogLevel);

            _gpuVendorName = GetGpuVendorName();

            Device.Gpu.Renderer.RunLoop(() =>
            {
                Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
                Translator.IsReadyForTranslation.Set();

                while (_isActive)
                {
                    if (_isStopped)
                    {
                        return;
                    }

                    _ticks += _chrono.ElapsedTicks;

                    _chrono.Restart();

                    if (Device.WaitFifo())
                    {
                        Device.Statistics.RecordFifoStart();
                        Device.ProcessFrame();
                        Device.Statistics.RecordFifoEnd();
                    }

                    while (Device.ConsumeFrameAvailable())
                    {
                        Device.PresentFrame(SwapBuffers);
                    }

                    if (_ticks >= _ticksPerFrame)
                    {
                        string dockedMode = Device.System.State.DockedMode ? "Docked" : "Handheld";
                        float scale       = Graphics.Gpu.GraphicsConfig.ResScale;
                        if (scale != 1)
                        {
                            dockedMode += $" ({scale}x)";
                        }

                        StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
                                                       Device.EnableDeviceVsync,
                                                       dockedMode,
                                                       Device.Configuration.AspectRatio.ToText(),
                                                       $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
                                                       $"FIFO: {Device.Statistics.GetFifoPercent():0.00} %",
                                                       $"GPU: {_gpuVendorName}"));

                        _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame);
                    }
                }
            });

            FinalizeRenderer();
        }
Пример #2
0
        private void _storeStatus(string statusData)
        {
            try
            {
                var evt = JsonConvert.DeserializeObject <EventWrapper>(statusData);

                var type    = $"EnergyHost.Model.EnergyModels.Status.{evt.EventName}, EnergyHost.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                var tActual = Type.GetType(type);

                var decodedType = JsonConvert.DeserializeObject(evt.Data, tActual);

                _statuses[evt.EventName] = decodedType;
                _history.Add(new KeyValuePair <string, object>(evt.EventName, decodedType));

                while (_history.Count > 5000)
                {
                    _history.RemoveAt(_history.Count - 1);
                }

                StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs {
                    StatusName = evt.EventName
                });
            }
            catch (Exception ex)
            {
                _logService.WriteError(ex);
            }
        }
Пример #3
0
        public void Render()
        {
            // First take exclusivity on the OpenGL context.
            _renderer.InitializeBackgroundContext(GraphicsContext);
            Gtk.Window parent = Toplevel as Gtk.Window;
            parent.Present();
            GraphicsContext.MakeCurrent(WindowInfo);

            _device.Gpu.Renderer.Initialize(_glLogLevel);

            // Make sure the first frame is not transparent.
            GL.ClearColor(OpenTK.Color.Black);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            SwapBuffers();

            _device.Gpu.InitializeShaderCache();
            Translator.IsReadyForTranslation.Set();

            while (_isActive)
            {
                if (_isStopped)
                {
                    return;
                }

                _ticks += _chrono.ElapsedTicks;

                _chrono.Restart();

                if (_device.WaitFifo())
                {
                    _device.Statistics.RecordFifoStart();
                    _device.ProcessFrame();
                    _device.Statistics.RecordFifoEnd();
                }

                string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld";
                float  scale      = Graphics.Gpu.GraphicsConfig.ResScale;
                if (scale != 1)
                {
                    dockedMode += $" ({scale}x)";
                }

                if (_ticks >= _ticksPerFrame)
                {
                    _device.PresentFrame(SwapBuffers);

                    StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
                                                   _device.EnableDeviceVsync,
                                                   dockedMode,
                                                   $"Game: {_device.Statistics.GetGameFrameRate():00.00} FPS",
                                                   $"FIFO: {_device.Statistics.GetFifoPercent():0.00} %",
                                                   $"GPU:  {_renderer.GpuVendor}"));

                    _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame);
                }
            }
        }
Пример #4
0
        private void TriggerStatusUpdatedEvent()
        {
            StatusUpdatedEvent handler = Events[StatusUpdatedEventKey] as StatusUpdatedEvent;

            if (handler != null)
            {
                handler.Invoke(this, EventArgs.Empty);
            }
        }
Пример #5
0
        public void Render()
        {
            // First take exclusivity on the OpenGL context.
            GraphicsContext.MakeCurrent(WindowInfo);

            _renderer.Initialize();

            // Shader cache setup.
            string basePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
            string workPath = System.IO.Path.Combine(basePath, "games", _device.System.TitleIdText, "cache", "gpu");

            _device.Gpu.SetShaderCachePath(workPath);
            _device.Gpu.LoadShaderCache();

            // Make sure the first frame is not transparent.
            GL.ClearColor(OpenTK.Color.Black);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            SwapBuffers();

            while (IsActive)
            {
                if (IsStopped)
                {
                    return;
                }

                _ticks += _chrono.ElapsedTicks;

                _chrono.Restart();

                if (_device.WaitFifo())
                {
                    _device.ProcessFrame();
                }

                if (_ticks >= _ticksPerFrame)
                {
                    _device.PresentFrame(SwapBuffers);

                    _device.Statistics.RecordSystemFrameTime();

                    StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
                                                   _device.EnableDeviceVsync,
                                                   $"Host: {_device.Statistics.GetSystemFrameRate():00.00} FPS",
                                                   $"Game: {_device.Statistics.GetGameFrameRate():00.00} FPS"));

                    _device.System.SignalVsync();

                    _device.VsyncEvent.Set();

                    _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame);
                }
            }
        }
Пример #6
0
        public void Render()
        {
            // First take exclusivity on the OpenGL context.
            GraphicsContext.MakeCurrent(WindowInfo);

            _renderer.Initialize();

            // Make sure the first frame is not transparent.
            GL.ClearColor(OpenTK.Color.Black);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            SwapBuffers();

            while (IsActive)
            {
                if (IsStopped)
                {
                    return;
                }

                _ticks += _chrono.ElapsedTicks;

                _chrono.Restart();

                if (_device.WaitFifo())
                {
                    _device.ProcessFrame();
                }

                if (_ticks >= _ticksPerFrame)
                {
                    _device.PresentFrame(SwapBuffers);

                    _device.Statistics.RecordSystemFrameTime();

                    StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
                                                   _device.EnableDeviceVsync,
                                                   $"Host: {_device.Statistics.GetSystemFrameRate():00.00} FPS",
                                                   $"Game: {_device.Statistics.GetGameFrameRate():00.00} FPS",
                                                   $"GPU: {_renderer.GpuVendor}"));

                    _device.System.SignalVsync();

                    _device.VsyncEvent.Set();

                    _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame);
                }
            }
        }
Пример #7
0
        public void Render()
        {
            Gtk.Window parent = Toplevel as Gtk.Window;
            parent.Present();

            InitializeRenderer();

            Device.Gpu.Renderer.Initialize(_glLogLevel);

            _gpuBackendName = GetGpuBackendName();
            _gpuVendorName  = GetGpuVendorName();

            Device.Gpu.Renderer.RunLoop(() =>
            {
                Device.Gpu.SetGpuThread();
                Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
                Translator.IsReadyForTranslation.Set();

                Renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);

                (Toplevel as MainWindow)?.ActivatePauseMenu();

                while (_isActive)
                {
                    if (_isStopped)
                    {
                        return;
                    }

                    _ticks += _chrono.ElapsedTicks;

                    _chrono.Restart();

                    if (Device.WaitFifo())
                    {
                        Device.Statistics.RecordFifoStart();
                        Device.ProcessFrame();
                        Device.Statistics.RecordFifoEnd();
                    }

                    while (Device.ConsumeFrameAvailable())
                    {
                        Device.PresentFrame((texture) => { SwapBuffers(texture); });
                    }

                    if (_ticks >= _ticksPerFrame)
                    {
                        string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld";
                        float scale       = Graphics.Gpu.GraphicsConfig.ResScale;
                        if (scale != 1)
                        {
                            dockedMode += $" ({scale}x)";
                        }

                        StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
                                                       Device.EnableDeviceVsync,
                                                       Device.GetVolume(),
                                                       _gpuBackendName,
                                                       dockedMode,
                                                       ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
                                                       $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
                                                       $"FIFO: {Device.Statistics.GetFifoPercent():0.00} %",
                                                       $"GPU: {_gpuVendorName}"));

                        _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame);
                    }
                }
            });
        }