Files
eden/src/video_core/renderer_base.h
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

109 lines
3.1 KiB
C++
Raw Normal View History

2022-05-15 02:06:02 +02:00
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2014-04-05 16:04:25 -04:00
#pragma once
#include <atomic>
#include <functional>
2015-06-21 14:58:59 +01:00
#include <memory>
#include "common/common_funcs.h"
2015-05-06 04:06:12 -03:00
#include "common/common_types.h"
#include "core/frontend/framebuffer_layout.h"
#include "video_core/gpu.h"
2018-03-22 19:46:37 -04:00
#include "video_core/rasterizer_interface.h"
2015-05-18 21:21:33 -07:00
2018-08-11 20:20:19 -04:00
namespace Core::Frontend {
2015-06-27 17:56:17 +01:00
class EmuWindow;
2020-06-11 00:58:57 -03:00
class GraphicsContext;
} // namespace Core::Frontend
2015-06-27 17:56:17 +01:00
namespace VideoCore {
struct RendererSettings {
2018-08-31 14:16:16 +08:00
// Screenshot
std::atomic<bool> screenshot_requested{false};
2020-06-11 00:58:57 -03:00
void* screenshot_bits{};
std::function<void(bool)> screenshot_complete_callback;
2018-08-31 14:16:16 +08:00
Layout::FramebufferLayout screenshot_framebuffer_layout;
};
class RendererBase {
2014-04-05 16:04:25 -04:00
public:
YUZU_NON_COPYABLE(RendererBase);
YUZU_NON_MOVEABLE(RendererBase);
2020-06-11 00:58:57 -03:00
explicit RendererBase(Core::Frontend::EmuWindow& window,
std::unique_ptr<Core::Frontend::GraphicsContext> context);
virtual ~RendererBase();
2014-04-05 16:04:25 -04:00
/// Finalize rendering the guest frame and draw into the presentation texture
virtual void Composite(std::span<const Tegra::FramebufferConfig> layers) = 0;
2024-01-26 16:10:21 -05:00
/// Get the tiled applet layer capture buffer
virtual std::vector<u8> GetAppletCaptureBuffer() = 0;
2021-01-05 04:09:39 -03:00
[[nodiscard]] virtual RasterizerInterface* ReadRasterizer() = 0;
[[nodiscard]] virtual std::string GetDeviceVendor() const = 0;
2014-04-05 16:04:25 -04:00
// Getter/setter functions:
// ------------------------
[[nodiscard]] f32 GetCurrentFPS() const {
2014-04-08 18:59:02 -04:00
return m_current_fps;
}
2014-04-05 16:04:25 -04:00
[[nodiscard]] int GetCurrentFrame() const {
2014-04-08 18:59:02 -04:00
return m_current_frame;
}
2014-04-05 16:04:25 -04:00
[[nodiscard]] Core::Frontend::GraphicsContext& Context() {
2020-06-11 00:58:57 -03:00
return *context;
}
[[nodiscard]] const Core::Frontend::GraphicsContext& Context() const {
2020-06-11 00:58:57 -03:00
return *context;
}
[[nodiscard]] Core::Frontend::EmuWindow& GetRenderWindow() {
2018-08-31 14:16:16 +08:00
return render_window;
}
[[nodiscard]] const Core::Frontend::EmuWindow& GetRenderWindow() const {
2018-08-31 14:16:16 +08:00
return render_window;
}
[[nodiscard]] RendererSettings& Settings() {
2018-08-31 14:16:16 +08:00
return renderer_settings;
}
[[nodiscard]] const RendererSettings& Settings() const {
2018-08-31 14:16:16 +08:00
return renderer_settings;
}
/// Refreshes the settings common to all renderers
void RefreshBaseSettings();
2015-05-18 21:21:33 -07:00
/// Returns true if a screenshot is being processed
bool IsScreenshotPending() const;
2018-08-31 14:16:16 +08:00
/// Request a screenshot of the next frame
void RequestScreenshot(void* data, std::function<void(bool)> callback,
2018-08-31 14:16:16 +08:00
const Layout::FramebufferLayout& layout);
2014-04-05 16:04:25 -04:00
protected:
2018-08-11 20:20:19 -04:00
Core::Frontend::EmuWindow& render_window; ///< Reference to the render window handle.
2020-06-11 00:58:57 -03:00
std::unique_ptr<Core::Frontend::GraphicsContext> context;
2016-09-18 09:38:01 +09:00
f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer
int m_current_frame = 0; ///< Current frame, should be set by the renderer
RendererSettings renderer_settings;
private:
/// Updates the framebuffer layout of the contained render window handle.
void UpdateCurrentFramebufferLayout();
2014-04-05 16:04:25 -04:00
};
} // namespace VideoCore