2020-01-28 14:57:30 +01:00
|
|
|
// Copyright 2020 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <memory>
|
2023-08-08 03:21:28 +02:00
|
|
|
|
|
|
|
#include "common/polyfill_thread.h"
|
2020-01-28 14:57:30 +01:00
|
|
|
#include "core/frontend/framebuffer_layout.h"
|
|
|
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
|
|
|
|
|
|
|
namespace Frontend {
|
|
|
|
class EmuWindow;
|
|
|
|
class GraphicsContext;
|
|
|
|
class TextureMailbox;
|
|
|
|
} // namespace Frontend
|
|
|
|
|
2023-08-08 03:21:28 +02:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2020-01-28 14:57:30 +01:00
|
|
|
namespace OpenGL {
|
|
|
|
|
|
|
|
class RendererOpenGL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the 'presentation' part in frame dumping.
|
|
|
|
* Processes frames/textures sent to its mailbox, downloads the pixels and sends the data
|
|
|
|
* to the video encoding backend.
|
|
|
|
*/
|
|
|
|
class FrameDumperOpenGL {
|
|
|
|
public:
|
2023-06-17 01:06:18 +02:00
|
|
|
explicit FrameDumperOpenGL(Core::System& system, Frontend::EmuWindow& emu_window);
|
2020-01-28 14:57:30 +01:00
|
|
|
~FrameDumperOpenGL();
|
|
|
|
|
|
|
|
bool IsDumping() const;
|
|
|
|
Layout::FramebufferLayout GetLayout() const;
|
|
|
|
void StartDumping();
|
|
|
|
void StopDumping();
|
|
|
|
|
|
|
|
std::unique_ptr<Frontend::TextureMailbox> mailbox;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void InitializeOpenGLObjects();
|
|
|
|
void CleanupOpenGLObjects();
|
2023-08-08 03:21:28 +02:00
|
|
|
void PresentLoop(std::stop_token stop_token);
|
2020-01-28 14:57:30 +01:00
|
|
|
|
2023-08-08 03:21:28 +02:00
|
|
|
private:
|
2023-06-17 01:06:18 +02:00
|
|
|
Core::System& system;
|
2020-01-28 14:57:30 +01:00
|
|
|
std::unique_ptr<Frontend::GraphicsContext> context;
|
2023-08-08 03:21:28 +02:00
|
|
|
std::jthread present_thread;
|
2020-01-28 14:57:30 +01:00
|
|
|
|
|
|
|
// PBOs used to dump frames faster
|
|
|
|
std::array<OGLBuffer, 2> pbos;
|
|
|
|
GLuint current_pbo = 1;
|
|
|
|
GLuint next_pbo = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OpenGL
|