2014-04-09 04:34:25 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 11:08:14 +05:30
|
|
|
// Licensed under GPLv2 or any later version
|
2014-04-09 04:34:25 +05:30
|
|
|
// Refer to the license.txt file included.
|
2014-04-06 01:34:25 +05:30
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-05-06 12:36:12 +05:30
|
|
|
#include "common/common_types.h"
|
2023-03-27 16:59:17 +05:30
|
|
|
#include "core/frontend/framebuffer_layout.h"
|
2015-12-07 08:36:12 +05:30
|
|
|
#include "video_core/rasterizer_interface.h"
|
2015-05-19 09:51:33 +05:30
|
|
|
|
2018-08-12 05:50:19 +05:30
|
|
|
namespace Frontend {
|
2015-06-27 22:26:17 +05:30
|
|
|
class EmuWindow;
|
2018-08-12 05:50:19 +05:30
|
|
|
}
|
2015-06-27 22:26:17 +05:30
|
|
|
|
2023-03-27 16:59:17 +05:30
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace VideoCore {
|
|
|
|
|
2023-06-24 04:29:18 +05:30
|
|
|
enum class ScreenId : u32 {
|
|
|
|
TopLeft,
|
|
|
|
TopRight,
|
|
|
|
Bottom,
|
|
|
|
};
|
|
|
|
|
2023-03-27 16:59:17 +05:30
|
|
|
struct RendererSettings {
|
|
|
|
// Screenshot
|
|
|
|
std::atomic_bool screenshot_requested{false};
|
|
|
|
void* screenshot_bits{};
|
2023-10-23 01:23:14 +05:30
|
|
|
std::function<void(bool)> screenshot_complete_callback;
|
2023-03-27 16:59:17 +05:30
|
|
|
Layout::FramebufferLayout screenshot_framebuffer_layout;
|
2023-03-30 16:54:49 +05:30
|
|
|
// Renderer
|
|
|
|
std::atomic_bool bg_color_update_requested{false};
|
|
|
|
std::atomic_bool shader_update_requested{false};
|
2023-03-27 16:59:17 +05:30
|
|
|
};
|
|
|
|
|
2014-04-28 03:59:51 +05:30
|
|
|
class RendererBase : NonCopyable {
|
2014-04-06 01:34:25 +05:30
|
|
|
public:
|
2023-03-27 16:59:17 +05:30
|
|
|
explicit RendererBase(Core::System& system, Frontend::EmuWindow& window,
|
|
|
|
Frontend::EmuWindow* secondary_window);
|
2018-08-24 18:48:46 +05:30
|
|
|
virtual ~RendererBase();
|
2014-04-06 01:34:25 +05:30
|
|
|
|
2023-03-27 16:59:17 +05:30
|
|
|
/// Returns the rasterizer owned by the renderer
|
2023-08-02 04:10:39 +05:30
|
|
|
virtual VideoCore::RasterizerInterface* Rasterizer() = 0;
|
2019-01-26 19:52:25 +05:30
|
|
|
|
2019-09-17 08:07:43 +05:30
|
|
|
/// Finalize rendering the guest frame and draw into the presentation texture
|
|
|
|
virtual void SwapBuffers() = 0;
|
|
|
|
|
2019-09-19 12:36:28 +05:30
|
|
|
/// Draws the latest frame to the window waiting timeout_ms for a frame to arrive (Renderer
|
|
|
|
/// specific implementation)
|
2022-11-17 21:07:30 +05:30
|
|
|
virtual void TryPresent(int timeout_ms, bool is_secondary) = 0;
|
|
|
|
virtual void TryPresent(int timeout_ms) {
|
|
|
|
TryPresent(timeout_ms, false);
|
|
|
|
}
|
2019-09-17 08:07:43 +05:30
|
|
|
|
2019-01-26 19:52:25 +05:30
|
|
|
/// Prepares for video dumping (e.g. create necessary buffers, etc)
|
2023-03-27 16:59:17 +05:30
|
|
|
virtual void PrepareVideoDumping() {}
|
2019-01-26 19:52:25 +05:30
|
|
|
|
|
|
|
/// Cleans up after video dumping is ended
|
2023-03-27 16:59:17 +05:30
|
|
|
virtual void CleanupVideoDumping() {}
|
|
|
|
|
|
|
|
/// Synchronizes fixed function renderer state
|
|
|
|
virtual void Sync() {}
|
2014-04-06 01:34:25 +05:30
|
|
|
|
2023-09-13 03:58:50 +05:30
|
|
|
/// This is called to notify the rendering backend of a surface change
|
|
|
|
virtual void NotifySurfaceChanged() {}
|
|
|
|
|
2023-03-30 16:54:49 +05:30
|
|
|
/// Returns the resolution scale factor relative to the native 3DS screen resolution
|
|
|
|
u32 GetResolutionScaleFactor();
|
|
|
|
|
2018-08-24 18:48:46 +05:30
|
|
|
/// Updates the framebuffer layout of the contained render window handle.
|
2019-07-23 00:28:54 +05:30
|
|
|
void UpdateCurrentFramebufferLayout(bool is_portrait_mode = {});
|
2018-08-24 18:48:46 +05:30
|
|
|
|
2023-03-27 16:59:17 +05:30
|
|
|
/// Ends the current frame
|
|
|
|
void EndFrame();
|
|
|
|
|
2016-03-09 08:09:44 +05:30
|
|
|
f32 GetCurrentFPS() const {
|
2023-03-27 16:59:17 +05:30
|
|
|
return current_fps;
|
2014-04-09 04:29:02 +05:30
|
|
|
}
|
2014-04-06 01:34:25 +05:30
|
|
|
|
2023-06-24 04:29:18 +05:30
|
|
|
s32 GetCurrentFrame() const {
|
2023-03-27 16:59:17 +05:30
|
|
|
return current_frame;
|
2016-03-09 08:01:41 +05:30
|
|
|
}
|
2015-12-07 08:36:12 +05:30
|
|
|
|
2018-08-12 05:50:19 +05:30
|
|
|
Frontend::EmuWindow& GetRenderWindow() {
|
2019-02-06 02:34:36 +05:30
|
|
|
return render_window;
|
|
|
|
}
|
|
|
|
|
2018-08-12 05:50:19 +05:30
|
|
|
const Frontend::EmuWindow& GetRenderWindow() const {
|
2018-08-24 18:48:46 +05:30
|
|
|
return render_window;
|
|
|
|
}
|
|
|
|
|
2023-03-27 16:59:17 +05:30
|
|
|
[[nodiscard]] RendererSettings& Settings() {
|
2023-03-30 16:54:49 +05:30
|
|
|
return settings;
|
2023-03-27 16:59:17 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] const RendererSettings& Settings() const {
|
2023-03-30 16:54:49 +05:30
|
|
|
return settings;
|
2023-03-27 16:59:17 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns true if a screenshot is being processed
|
|
|
|
[[nodiscard]] bool IsScreenshotPending() const;
|
|
|
|
|
|
|
|
/// Request a screenshot of the next frame
|
2023-10-23 01:23:14 +05:30
|
|
|
void RequestScreenshot(void* data, std::function<void(bool)> callback,
|
2023-03-27 16:59:17 +05:30
|
|
|
const Layout::FramebufferLayout& layout);
|
2015-05-19 09:51:33 +05:30
|
|
|
|
2014-04-06 01:34:25 +05:30
|
|
|
protected:
|
2023-03-27 16:59:17 +05:30
|
|
|
Core::System& system;
|
2023-03-30 16:54:49 +05:30
|
|
|
RendererSettings settings;
|
2022-11-17 21:07:30 +05:30
|
|
|
Frontend::EmuWindow& render_window; ///< Reference to the render window handle.
|
|
|
|
Frontend::EmuWindow* secondary_window; ///< Reference to the secondary render window handle.
|
2023-03-27 16:59:17 +05:30
|
|
|
f32 current_fps = 0.0f; ///< Current framerate, should be set by the renderer
|
2023-06-24 04:29:18 +05:30
|
|
|
s32 current_frame = 0; ///< Current frame, should be set by the renderer
|
2014-04-06 01:34:25 +05:30
|
|
|
};
|
2023-03-27 16:59:17 +05:30
|
|
|
|
|
|
|
} // namespace VideoCore
|