renderer_base.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <atomic>
  6. #include <memory>
  7. #include <boost/optional.hpp>
  8. #include "common/common_types.h"
  9. #include "video_core/gpu.h"
  10. #include "video_core/rasterizer_interface.h"
  11. class EmuWindow;
  12. namespace VideoCore {
  13. struct RendererSettings {
  14. std::atomic_bool use_framelimiter{false};
  15. };
  16. class RendererBase : NonCopyable {
  17. public:
  18. explicit RendererBase(EmuWindow& window);
  19. virtual ~RendererBase();
  20. /// Swap buffers (render frame)
  21. virtual void SwapBuffers(boost::optional<const Tegra::FramebufferConfig&> framebuffer) = 0;
  22. /// Initialize the renderer
  23. virtual bool Init() = 0;
  24. /// Shutdown the renderer
  25. virtual void ShutDown() = 0;
  26. // Getter/setter functions:
  27. // ------------------------
  28. f32 GetCurrentFPS() const {
  29. return m_current_fps;
  30. }
  31. int GetCurrentFrame() const {
  32. return m_current_frame;
  33. }
  34. RasterizerInterface& Rasterizer() {
  35. return *rasterizer;
  36. }
  37. const RasterizerInterface& Rasterizer() const {
  38. return *rasterizer;
  39. }
  40. /// Refreshes the settings common to all renderers
  41. void RefreshBaseSettings();
  42. protected:
  43. /// Refreshes settings specific to the rasterizer.
  44. void RefreshRasterizerSetting();
  45. EmuWindow& render_window; ///< Reference to the render window handle.
  46. std::unique_ptr<RasterizerInterface> rasterizer;
  47. f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer
  48. int m_current_frame = 0; ///< Current frame, should be set by the renderer
  49. RendererSettings renderer_settings;
  50. private:
  51. /// Updates the framebuffer layout of the contained render window handle.
  52. void UpdateCurrentFramebufferLayout();
  53. };
  54. } // namespace VideoCore