Dynamically load FFmpeg and libfdk-aac if available. (#6570)

This commit is contained in:
Steveice10
2023-06-16 16:06:18 -07:00
committed by GitHub
parent d807cdfe62
commit 38435e9b3e
38 changed files with 1311 additions and 877 deletions

View File

@@ -3,32 +3,37 @@
// Refer to the license.txt file included.
#include <glad/glad.h>
#include <utility>
#include "core/frontend/emu_window.h"
#include "video_core/renderer_opengl/frame_dumper_opengl.h"
#include "video_core/renderer_opengl/renderer_opengl.h"
namespace OpenGL {
FrameDumperOpenGL::FrameDumperOpenGL(VideoDumper::Backend& video_dumper_,
Frontend::EmuWindow& emu_window)
: video_dumper(video_dumper_), context(emu_window.CreateSharedContext()) {}
FrameDumperOpenGL::FrameDumperOpenGL(Core::System& system_, Frontend::EmuWindow& emu_window)
: system(system_), context(emu_window.CreateSharedContext()) {}
FrameDumperOpenGL::~FrameDumperOpenGL() {
if (present_thread.joinable())
if (present_thread.joinable()) {
present_thread.join();
}
}
bool FrameDumperOpenGL::IsDumping() const {
return video_dumper.IsDumping();
auto video_dumper = system.GetVideoDumper();
return video_dumper && video_dumper->IsDumping();
}
Layout::FramebufferLayout FrameDumperOpenGL::GetLayout() const {
return video_dumper.GetLayout();
auto video_dumper = system.GetVideoDumper();
return video_dumper ? video_dumper->GetLayout() : Layout::FramebufferLayout{};
}
void FrameDumperOpenGL::StartDumping() {
if (present_thread.joinable())
if (present_thread.joinable()) {
present_thread.join();
}
present_thread = std::thread(&FrameDumperOpenGL::PresentLoop, this);
}
@@ -62,13 +67,17 @@ void FrameDumperOpenGL::PresentLoop() {
frame->present_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
// Bind the previous PBO and read the pixels
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbos[next_pbo].handle);
GLubyte* pixels = static_cast<GLubyte*>(glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY));
VideoDumper::VideoFrame frame_data{layout.width, layout.height, pixels};
video_dumper.AddVideoFrame(std::move(frame_data));
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
auto video_dumper = system.GetVideoDumper();
if (video_dumper) {
// Bind the previous PBO and read the pixels
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbos[next_pbo].handle);
GLubyte* pixels =
static_cast<GLubyte*>(glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY));
VideoDumper::VideoFrame frame_data{layout.width, layout.height, pixels};
video_dumper->AddVideoFrame(std::move(frame_data));
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
}
current_pbo = (current_pbo + 1) % 2;
next_pbo = (current_pbo + 1) % 2;

View File

@@ -7,6 +7,7 @@
#include <atomic>
#include <memory>
#include <thread>
#include "core/core.h"
#include "core/dumping/backend.h"
#include "core/frontend/framebuffer_layout.h"
#include "video_core/renderer_opengl/gl_resource_manager.h"
@@ -28,7 +29,7 @@ class RendererOpenGL;
*/
class FrameDumperOpenGL {
public:
explicit FrameDumperOpenGL(VideoDumper::Backend& video_dumper, Frontend::EmuWindow& emu_window);
explicit FrameDumperOpenGL(Core::System& system, Frontend::EmuWindow& emu_window);
~FrameDumperOpenGL();
bool IsDumping() const;
@@ -43,7 +44,7 @@ private:
void CleanupOpenGLObjects();
void PresentLoop();
VideoDumper::Backend& video_dumper;
Core::System& system;
std::unique_ptr<Frontend::GraphicsContext> context;
std::thread present_thread;
std::atomic_bool stop_requested{false};

View File

@@ -306,7 +306,7 @@ static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, cons
RendererOpenGL::RendererOpenGL(Core::System& system, Frontend::EmuWindow& window,
Frontend::EmuWindow* secondary_window)
: VideoCore::RendererBase{system, window, secondary_window}, driver{system.TelemetrySession()},
frame_dumper{system.VideoDumper(), window} {
frame_dumper{system, window} {
const bool has_debug_tool = driver.HasDebugTool();
window.mailbox = std::make_unique<OGLTextureMailbox>(has_debug_tool);
if (secondary_window) {