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