Merge pull request #12500 from AdmiralCurtiss/globals-fiforecorder
FifoRecorder: Move instance to System.
This commit is contained in:
commit
8760aca8ec
|
@ -213,9 +213,11 @@ void FifoRecorder::FifoRecordAnalyzer::ProcessVertexComponent(
|
||||||
m_owner->UseMemory(array_start, array_size, MemoryUpdate::Type::VertexStream);
|
m_owner->UseMemory(array_start, array_size, MemoryUpdate::Type::VertexStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FifoRecorder instance;
|
FifoRecorder::FifoRecorder(Core::System& system) : m_system(system)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
FifoRecorder::FifoRecorder() = default;
|
FifoRecorder::~FifoRecorder() = default;
|
||||||
|
|
||||||
void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
||||||
{
|
{
|
||||||
|
@ -235,8 +237,7 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
||||||
// - Global variables suck
|
// - Global variables suck
|
||||||
// - Multithreading with the above two sucks
|
// - Multithreading with the above two sucks
|
||||||
//
|
//
|
||||||
auto& system = Core::System::GetInstance();
|
auto& memory = m_system.GetMemory();
|
||||||
auto& memory = system.GetMemory();
|
|
||||||
m_Ram.resize(memory.GetRamSize());
|
m_Ram.resize(memory.GetRamSize());
|
||||||
m_ExRam.resize(memory.GetExRamSize());
|
m_ExRam.resize(memory.GetExRamSize());
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
||||||
RecordInitialVideoMemory();
|
RecordInitialVideoMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& fifo = Core::System::GetInstance().GetCommandProcessor().GetFifo();
|
const auto& fifo = m_system.GetCommandProcessor().GetFifo();
|
||||||
EndFrame(fifo.CPBase.load(std::memory_order_relaxed),
|
EndFrame(fifo.CPBase.load(std::memory_order_relaxed),
|
||||||
fifo.CPEnd.load(std::memory_order_relaxed));
|
fifo.CPEnd.load(std::memory_order_relaxed));
|
||||||
},
|
},
|
||||||
|
@ -356,8 +357,7 @@ void FifoRecorder::WriteGPCommand(const u8* data, u32 size)
|
||||||
|
|
||||||
void FifoRecorder::UseMemory(u32 address, u32 size, MemoryUpdate::Type type, bool dynamicUpdate)
|
void FifoRecorder::UseMemory(u32 address, u32 size, MemoryUpdate::Type type, bool dynamicUpdate)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& memory = m_system.GetMemory();
|
||||||
auto& memory = system.GetMemory();
|
|
||||||
|
|
||||||
u8* curData;
|
u8* curData;
|
||||||
u8* newData;
|
u8* newData;
|
||||||
|
@ -461,8 +461,3 @@ bool FifoRecorder::IsRecording() const
|
||||||
{
|
{
|
||||||
return m_IsRecording;
|
return m_IsRecording;
|
||||||
}
|
}
|
||||||
|
|
||||||
FifoRecorder& FifoRecorder::GetInstance()
|
|
||||||
{
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,12 +12,22 @@
|
||||||
#include "Common/HookableEvent.h"
|
#include "Common/HookableEvent.h"
|
||||||
#include "Core/FifoPlayer/FifoDataFile.h"
|
#include "Core/FifoPlayer/FifoDataFile.h"
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
class FifoRecorder
|
class FifoRecorder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using CallbackFunc = std::function<void()>;
|
using CallbackFunc = std::function<void()>;
|
||||||
|
|
||||||
FifoRecorder();
|
explicit FifoRecorder(Core::System& system);
|
||||||
|
FifoRecorder(const FifoRecorder&) = delete;
|
||||||
|
FifoRecorder(FifoRecorder&&) = delete;
|
||||||
|
FifoRecorder& operator=(const FifoRecorder&) = delete;
|
||||||
|
FifoRecorder& operator=(FifoRecorder&&) = delete;
|
||||||
|
~FifoRecorder();
|
||||||
|
|
||||||
void StartRecording(s32 numFrames, CallbackFunc finishedCb);
|
void StartRecording(s32 numFrames, CallbackFunc finishedCb);
|
||||||
void StopRecording();
|
void StopRecording();
|
||||||
|
@ -46,7 +56,6 @@ public:
|
||||||
|
|
||||||
// Checked once per frame prior to callng EndFrame()
|
// Checked once per frame prior to callng EndFrame()
|
||||||
bool IsRecording() const;
|
bool IsRecording() const;
|
||||||
static FifoRecorder& GetInstance();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class FifoRecordAnalyzer;
|
class FifoRecordAnalyzer;
|
||||||
|
@ -77,4 +86,6 @@ private:
|
||||||
std::vector<u8> m_ExRam;
|
std::vector<u8> m_ExRam;
|
||||||
|
|
||||||
Common::EventHook m_end_of_frame_event;
|
Common::EventHook m_end_of_frame_event;
|
||||||
|
|
||||||
|
Core::System& m_system;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/CoreTiming.h"
|
#include "Core/CoreTiming.h"
|
||||||
#include "Core/FifoPlayer/FifoPlayer.h"
|
#include "Core/FifoPlayer/FifoPlayer.h"
|
||||||
|
#include "Core/FifoPlayer/FifoRecorder.h"
|
||||||
#include "Core/HW/AudioInterface.h"
|
#include "Core/HW/AudioInterface.h"
|
||||||
#include "Core/HW/CPU.h"
|
#include "Core/HW/CPU.h"
|
||||||
#include "Core/HW/DSP.h"
|
#include "Core/HW/DSP.h"
|
||||||
|
@ -51,7 +52,7 @@ struct System::Impl
|
||||||
m_mmu(system, m_memory, m_power_pc), m_processor_interface(system),
|
m_mmu(system, m_memory, m_power_pc), m_processor_interface(system),
|
||||||
m_serial_interface(system), m_system_timers(system), m_video_interface(system),
|
m_serial_interface(system), m_system_timers(system), m_video_interface(system),
|
||||||
m_interpreter(system, m_power_pc.GetPPCState(), m_mmu), m_jit_interface(system),
|
m_interpreter(system, m_power_pc.GetPPCState(), m_mmu), m_jit_interface(system),
|
||||||
m_fifo_player(system)
|
m_fifo_player(system), m_fifo_recorder(system)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +92,7 @@ struct System::Impl
|
||||||
JitInterface m_jit_interface;
|
JitInterface m_jit_interface;
|
||||||
VideoCommon::CustomAssetLoader m_custom_asset_loader;
|
VideoCommon::CustomAssetLoader m_custom_asset_loader;
|
||||||
FifoPlayer m_fifo_player;
|
FifoPlayer m_fifo_player;
|
||||||
|
FifoRecorder m_fifo_recorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
System::System() : m_impl{std::make_unique<Impl>(*this)}
|
System::System() : m_impl{std::make_unique<Impl>(*this)}
|
||||||
|
@ -186,6 +188,11 @@ FifoPlayer& System::GetFifoPlayer() const
|
||||||
return m_impl->m_fifo_player;
|
return m_impl->m_fifo_player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FifoRecorder& System::GetFifoRecorder() const
|
||||||
|
{
|
||||||
|
return m_impl->m_fifo_recorder;
|
||||||
|
}
|
||||||
|
|
||||||
GeometryShaderManager& System::GetGeometryShaderManager() const
|
GeometryShaderManager& System::GetGeometryShaderManager() const
|
||||||
{
|
{
|
||||||
return m_impl->m_geometry_shader_manager;
|
return m_impl->m_geometry_shader_manager;
|
||||||
|
|
|
@ -48,6 +48,7 @@ namespace Fifo
|
||||||
class FifoManager;
|
class FifoManager;
|
||||||
}
|
}
|
||||||
class FifoPlayer;
|
class FifoPlayer;
|
||||||
|
class FifoRecorder;
|
||||||
namespace GPFifo
|
namespace GPFifo
|
||||||
{
|
{
|
||||||
class GPFifoManager;
|
class GPFifoManager;
|
||||||
|
@ -148,6 +149,7 @@ public:
|
||||||
ExpansionInterface::ExpansionInterfaceManager& GetExpansionInterface() const;
|
ExpansionInterface::ExpansionInterfaceManager& GetExpansionInterface() const;
|
||||||
Fifo::FifoManager& GetFifo() const;
|
Fifo::FifoManager& GetFifo() const;
|
||||||
FifoPlayer& GetFifoPlayer() const;
|
FifoPlayer& GetFifoPlayer() const;
|
||||||
|
FifoRecorder& GetFifoRecorder() const;
|
||||||
GeometryShaderManager& GetGeometryShaderManager() const;
|
GeometryShaderManager& GetGeometryShaderManager() const;
|
||||||
GPFifo::GPFifoManager& GetGPFifo() const;
|
GPFifo::GPFifoManager& GetGPFifo() const;
|
||||||
HSP::HSPManager& GetHSP() const;
|
HSP::HSPManager& GetHSP() const;
|
||||||
|
|
|
@ -32,8 +32,9 @@
|
||||||
#include "DolphinQt/Resources.h"
|
#include "DolphinQt/Resources.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
FIFOPlayerWindow::FIFOPlayerWindow(FifoPlayer& fifo_player, QWidget* parent)
|
FIFOPlayerWindow::FIFOPlayerWindow(FifoPlayer& fifo_player, FifoRecorder& fifo_recorder,
|
||||||
: QWidget(parent), m_fifo_player(fifo_player)
|
QWidget* parent)
|
||||||
|
: QWidget(parent), m_fifo_player(fifo_player), m_fifo_recorder(fifo_recorder)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("FIFO Player"));
|
setWindowTitle(tr("FIFO Player"));
|
||||||
setWindowIcon(Resources::GetAppIcon());
|
setWindowIcon(Resources::GetAppIcon());
|
||||||
|
@ -229,7 +230,7 @@ void FIFOPlayerWindow::SaveRecording()
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FifoDataFile* file = FifoRecorder::GetInstance().GetRecordedFile();
|
FifoDataFile* file = m_fifo_recorder.GetRecordedFile();
|
||||||
|
|
||||||
bool result = file->Save(path.toStdString());
|
bool result = file->Save(path.toStdString());
|
||||||
|
|
||||||
|
@ -242,9 +243,8 @@ void FIFOPlayerWindow::SaveRecording()
|
||||||
void FIFOPlayerWindow::StartRecording()
|
void FIFOPlayerWindow::StartRecording()
|
||||||
{
|
{
|
||||||
// Start recording
|
// Start recording
|
||||||
FifoRecorder::GetInstance().StartRecording(m_frame_record_count->value(), [this] {
|
m_fifo_recorder.StartRecording(m_frame_record_count->value(),
|
||||||
QueueOnObject(this, [this] { OnRecordingDone(); });
|
[this] { QueueOnObject(this, [this] { OnRecordingDone(); }); });
|
||||||
});
|
|
||||||
|
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ void FIFOPlayerWindow::StartRecording()
|
||||||
|
|
||||||
void FIFOPlayerWindow::StopRecording()
|
void FIFOPlayerWindow::StopRecording()
|
||||||
{
|
{
|
||||||
FifoRecorder::GetInstance().StopRecording();
|
m_fifo_recorder.StopRecording();
|
||||||
|
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
UpdateInfo();
|
UpdateInfo();
|
||||||
|
@ -270,7 +270,7 @@ void FIFOPlayerWindow::OnEmulationStarted()
|
||||||
void FIFOPlayerWindow::OnEmulationStopped()
|
void FIFOPlayerWindow::OnEmulationStopped()
|
||||||
{
|
{
|
||||||
// If we have previously been recording, stop now.
|
// If we have previously been recording, stop now.
|
||||||
if (FifoRecorder::GetInstance().IsRecording())
|
if (m_fifo_recorder.IsRecording())
|
||||||
StopRecording();
|
StopRecording();
|
||||||
|
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
|
@ -297,9 +297,9 @@ void FIFOPlayerWindow::UpdateInfo()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FifoRecorder::GetInstance().IsRecordingDone())
|
if (m_fifo_recorder.IsRecordingDone())
|
||||||
{
|
{
|
||||||
FifoDataFile* file = FifoRecorder::GetInstance().GetRecordedFile();
|
FifoDataFile* file = m_fifo_recorder.GetRecordedFile();
|
||||||
size_t fifo_bytes = 0;
|
size_t fifo_bytes = 0;
|
||||||
size_t mem_bytes = 0;
|
size_t mem_bytes = 0;
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ void FIFOPlayerWindow::UpdateInfo()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core::IsRunning() && FifoRecorder::GetInstance().IsRecording())
|
if (Core::IsRunning() && m_fifo_recorder.IsRecording())
|
||||||
{
|
{
|
||||||
m_info_label->setText(tr("Recording..."));
|
m_info_label->setText(tr("Recording..."));
|
||||||
return;
|
return;
|
||||||
|
@ -376,7 +376,7 @@ void FIFOPlayerWindow::UpdateLimits()
|
||||||
void FIFOPlayerWindow::UpdateControls()
|
void FIFOPlayerWindow::UpdateControls()
|
||||||
{
|
{
|
||||||
bool running = Core::IsRunning();
|
bool running = Core::IsRunning();
|
||||||
bool is_recording = FifoRecorder::GetInstance().IsRecording();
|
bool is_recording = m_fifo_recorder.IsRecording();
|
||||||
bool is_playing = m_fifo_player.IsPlaying();
|
bool is_playing = m_fifo_player.IsPlaying();
|
||||||
|
|
||||||
m_frame_range_from->setEnabled(is_playing);
|
m_frame_range_from->setEnabled(is_playing);
|
||||||
|
@ -399,7 +399,7 @@ void FIFOPlayerWindow::UpdateControls()
|
||||||
m_stop->setVisible(running && is_recording);
|
m_stop->setVisible(running && is_recording);
|
||||||
m_record->setVisible(!m_stop->isVisible());
|
m_record->setVisible(!m_stop->isVisible());
|
||||||
|
|
||||||
m_save->setEnabled(FifoRecorder::GetInstance().IsRecordingDone());
|
m_save->setEnabled(m_fifo_recorder.IsRecordingDone());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FIFOPlayerWindow::eventFilter(QObject* object, QEvent* event)
|
bool FIFOPlayerWindow::eventFilter(QObject* object, QEvent* event)
|
||||||
|
|
|
@ -14,13 +14,15 @@ class QSpinBox;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
class ToolTipCheckBox;
|
class ToolTipCheckBox;
|
||||||
class FifoPlayer;
|
class FifoPlayer;
|
||||||
|
class FifoRecorder;
|
||||||
class FIFOAnalyzer;
|
class FIFOAnalyzer;
|
||||||
|
|
||||||
class FIFOPlayerWindow : public QWidget
|
class FIFOPlayerWindow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit FIFOPlayerWindow(FifoPlayer& fifo_player, QWidget* parent = nullptr);
|
explicit FIFOPlayerWindow(FifoPlayer& fifo_player, FifoRecorder& fifo_recorder,
|
||||||
|
QWidget* parent = nullptr);
|
||||||
~FIFOPlayerWindow();
|
~FIFOPlayerWindow();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -51,6 +53,7 @@ private:
|
||||||
bool eventFilter(QObject* object, QEvent* event) final override;
|
bool eventFilter(QObject* object, QEvent* event) final override;
|
||||||
|
|
||||||
FifoPlayer& m_fifo_player;
|
FifoPlayer& m_fifo_player;
|
||||||
|
FifoRecorder& m_fifo_recorder;
|
||||||
|
|
||||||
QLabel* m_info_label;
|
QLabel* m_info_label;
|
||||||
QPushButton* m_load;
|
QPushButton* m_load;
|
||||||
|
|
|
@ -1363,7 +1363,8 @@ void MainWindow::ShowFIFOPlayer()
|
||||||
{
|
{
|
||||||
if (!m_fifo_window)
|
if (!m_fifo_window)
|
||||||
{
|
{
|
||||||
m_fifo_window = new FIFOPlayerWindow(Core::System::GetInstance().GetFifoPlayer());
|
m_fifo_window = new FIFOPlayerWindow(Core::System::GetInstance().GetFifoPlayer(),
|
||||||
|
Core::System::GetInstance().GetFifoRecorder());
|
||||||
connect(m_fifo_window, &FIFOPlayerWindow::LoadFIFORequested, this,
|
connect(m_fifo_window, &FIFOPlayerWindow::LoadFIFORequested, this,
|
||||||
[this](const QString& path) { StartGame(path, ScanForSecondDisc::No); });
|
[this](const QString& path) { StartGame(path, ScanForSecondDisc::No); });
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, XFStateManager&
|
||||||
memory.CopyFromEmu(texMem + tmem_addr, addr, tmem_transfer_count);
|
memory.CopyFromEmu(texMem + tmem_addr, addr, tmem_transfer_count);
|
||||||
|
|
||||||
if (OpcodeDecoder::g_record_fifo_data)
|
if (OpcodeDecoder::g_record_fifo_data)
|
||||||
FifoRecorder::GetInstance().UseMemory(addr, tmem_transfer_count, MemoryUpdate::Type::TMEM);
|
system.GetFifoRecorder().UseMemory(addr, tmem_transfer_count, MemoryUpdate::Type::TMEM);
|
||||||
|
|
||||||
TMEM::InvalidateAll();
|
TMEM::InvalidateAll();
|
||||||
|
|
||||||
|
@ -624,7 +624,10 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, XFStateManager&
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OpcodeDecoder::g_record_fifo_data)
|
if (OpcodeDecoder::g_record_fifo_data)
|
||||||
FifoRecorder::GetInstance().UseMemory(src_addr, bytes_read, MemoryUpdate::Type::TMEM);
|
{
|
||||||
|
Core::System::GetInstance().GetFifoRecorder().UseMemory(src_addr, bytes_read,
|
||||||
|
MemoryUpdate::Type::TMEM);
|
||||||
|
}
|
||||||
|
|
||||||
TMEM::InvalidateAll();
|
TMEM::InvalidateAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ public:
|
||||||
// process them.
|
// process them.
|
||||||
if (g_record_fifo_data && static_cast<Opcode>(data[0]) != Opcode::GX_CMD_CALL_DL)
|
if (g_record_fifo_data && static_cast<Opcode>(data[0]) != Opcode::GX_CMD_CALL_DL)
|
||||||
{
|
{
|
||||||
FifoRecorder::GetInstance().WriteGPCommand(data, size);
|
Core::System::GetInstance().GetFifoRecorder().WriteGPCommand(data, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1349,9 +1349,9 @@ RcTcacheEntry TextureCacheBase::GetTexture(const int textureCacheSafetyColorSamp
|
||||||
// its own memory modification tracking independent of the texture hashing below.
|
// its own memory modification tracking independent of the texture hashing below.
|
||||||
if (OpcodeDecoder::g_record_fifo_data && !texture_info.IsFromTmem())
|
if (OpcodeDecoder::g_record_fifo_data && !texture_info.IsFromTmem())
|
||||||
{
|
{
|
||||||
FifoRecorder::GetInstance().UseMemory(texture_info.GetRawAddress(),
|
Core::System::GetInstance().GetFifoRecorder().UseMemory(texture_info.GetRawAddress(),
|
||||||
texture_info.GetFullLevelSize(),
|
texture_info.GetFullLevelSize(),
|
||||||
MemoryUpdate::Type::TextureMap);
|
MemoryUpdate::Type::TextureMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This doesn't hash GB tiles for preloaded RGBA8 textures (instead, it's hashing more data
|
// TODO: This doesn't hash GB tiles for preloaded RGBA8 textures (instead, it's hashing more data
|
||||||
|
@ -2534,8 +2534,8 @@ void TextureCacheBase::CopyRenderTargetToTexture(
|
||||||
u32 address = dstAddr;
|
u32 address = dstAddr;
|
||||||
for (u32 i = 0; i < num_blocks_y; i++)
|
for (u32 i = 0; i < num_blocks_y; i++)
|
||||||
{
|
{
|
||||||
FifoRecorder::GetInstance().UseMemory(address, bytes_per_row, MemoryUpdate::Type::TextureMap,
|
Core::System::GetInstance().GetFifoRecorder().UseMemory(address, bytes_per_row,
|
||||||
true);
|
MemoryUpdate::Type::TextureMap, true);
|
||||||
address += dstStride;
|
address += dstStride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue