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);
|
||||
}
|
||||
|
||||
static FifoRecorder instance;
|
||||
FifoRecorder::FifoRecorder(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
FifoRecorder::FifoRecorder() = default;
|
||||
FifoRecorder::~FifoRecorder() = default;
|
||||
|
||||
void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
||||
{
|
||||
|
@ -235,8 +237,7 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
|||
// - Global variables suck
|
||||
// - Multithreading with the above two sucks
|
||||
//
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
auto& memory = m_system.GetMemory();
|
||||
m_Ram.resize(memory.GetRamSize());
|
||||
m_ExRam.resize(memory.GetExRamSize());
|
||||
|
||||
|
@ -272,7 +273,7 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
|||
RecordInitialVideoMemory();
|
||||
}
|
||||
|
||||
const auto& fifo = Core::System::GetInstance().GetCommandProcessor().GetFifo();
|
||||
const auto& fifo = m_system.GetCommandProcessor().GetFifo();
|
||||
EndFrame(fifo.CPBase.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)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
auto& memory = m_system.GetMemory();
|
||||
|
||||
u8* curData;
|
||||
u8* newData;
|
||||
|
@ -461,8 +461,3 @@ bool FifoRecorder::IsRecording() const
|
|||
{
|
||||
return m_IsRecording;
|
||||
}
|
||||
|
||||
FifoRecorder& FifoRecorder::GetInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -12,12 +12,22 @@
|
|||
#include "Common/HookableEvent.h"
|
||||
#include "Core/FifoPlayer/FifoDataFile.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
class FifoRecorder
|
||||
{
|
||||
public:
|
||||
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 StopRecording();
|
||||
|
@ -46,7 +56,6 @@ public:
|
|||
|
||||
// Checked once per frame prior to callng EndFrame()
|
||||
bool IsRecording() const;
|
||||
static FifoRecorder& GetInstance();
|
||||
|
||||
private:
|
||||
class FifoRecordAnalyzer;
|
||||
|
@ -77,4 +86,6 @@ private:
|
|||
std::vector<u8> m_ExRam;
|
||||
|
||||
Common::EventHook m_end_of_frame_event;
|
||||
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/FifoPlayer/FifoPlayer.h"
|
||||
#include "Core/FifoPlayer/FifoRecorder.h"
|
||||
#include "Core/HW/AudioInterface.h"
|
||||
#include "Core/HW/CPU.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_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_fifo_player(system)
|
||||
m_fifo_player(system), m_fifo_recorder(system)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -91,6 +92,7 @@ struct System::Impl
|
|||
JitInterface m_jit_interface;
|
||||
VideoCommon::CustomAssetLoader m_custom_asset_loader;
|
||||
FifoPlayer m_fifo_player;
|
||||
FifoRecorder m_fifo_recorder;
|
||||
};
|
||||
|
||||
System::System() : m_impl{std::make_unique<Impl>(*this)}
|
||||
|
@ -186,6 +188,11 @@ FifoPlayer& System::GetFifoPlayer() const
|
|||
return m_impl->m_fifo_player;
|
||||
}
|
||||
|
||||
FifoRecorder& System::GetFifoRecorder() const
|
||||
{
|
||||
return m_impl->m_fifo_recorder;
|
||||
}
|
||||
|
||||
GeometryShaderManager& System::GetGeometryShaderManager() const
|
||||
{
|
||||
return m_impl->m_geometry_shader_manager;
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace Fifo
|
|||
class FifoManager;
|
||||
}
|
||||
class FifoPlayer;
|
||||
class FifoRecorder;
|
||||
namespace GPFifo
|
||||
{
|
||||
class GPFifoManager;
|
||||
|
@ -148,6 +149,7 @@ public:
|
|||
ExpansionInterface::ExpansionInterfaceManager& GetExpansionInterface() const;
|
||||
Fifo::FifoManager& GetFifo() const;
|
||||
FifoPlayer& GetFifoPlayer() const;
|
||||
FifoRecorder& GetFifoRecorder() const;
|
||||
GeometryShaderManager& GetGeometryShaderManager() const;
|
||||
GPFifo::GPFifoManager& GetGPFifo() const;
|
||||
HSP::HSPManager& GetHSP() const;
|
||||
|
|
|
@ -32,8 +32,9 @@
|
|||
#include "DolphinQt/Resources.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
FIFOPlayerWindow::FIFOPlayerWindow(FifoPlayer& fifo_player, QWidget* parent)
|
||||
: QWidget(parent), m_fifo_player(fifo_player)
|
||||
FIFOPlayerWindow::FIFOPlayerWindow(FifoPlayer& fifo_player, FifoRecorder& fifo_recorder,
|
||||
QWidget* parent)
|
||||
: QWidget(parent), m_fifo_player(fifo_player), m_fifo_recorder(fifo_recorder)
|
||||
{
|
||||
setWindowTitle(tr("FIFO Player"));
|
||||
setWindowIcon(Resources::GetAppIcon());
|
||||
|
@ -229,7 +230,7 @@ void FIFOPlayerWindow::SaveRecording()
|
|||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
FifoDataFile* file = FifoRecorder::GetInstance().GetRecordedFile();
|
||||
FifoDataFile* file = m_fifo_recorder.GetRecordedFile();
|
||||
|
||||
bool result = file->Save(path.toStdString());
|
||||
|
||||
|
@ -242,9 +243,8 @@ void FIFOPlayerWindow::SaveRecording()
|
|||
void FIFOPlayerWindow::StartRecording()
|
||||
{
|
||||
// Start recording
|
||||
FifoRecorder::GetInstance().StartRecording(m_frame_record_count->value(), [this] {
|
||||
QueueOnObject(this, [this] { OnRecordingDone(); });
|
||||
});
|
||||
m_fifo_recorder.StartRecording(m_frame_record_count->value(),
|
||||
[this] { QueueOnObject(this, [this] { OnRecordingDone(); }); });
|
||||
|
||||
UpdateControls();
|
||||
|
||||
|
@ -253,7 +253,7 @@ void FIFOPlayerWindow::StartRecording()
|
|||
|
||||
void FIFOPlayerWindow::StopRecording()
|
||||
{
|
||||
FifoRecorder::GetInstance().StopRecording();
|
||||
m_fifo_recorder.StopRecording();
|
||||
|
||||
UpdateControls();
|
||||
UpdateInfo();
|
||||
|
@ -270,7 +270,7 @@ void FIFOPlayerWindow::OnEmulationStarted()
|
|||
void FIFOPlayerWindow::OnEmulationStopped()
|
||||
{
|
||||
// If we have previously been recording, stop now.
|
||||
if (FifoRecorder::GetInstance().IsRecording())
|
||||
if (m_fifo_recorder.IsRecording())
|
||||
StopRecording();
|
||||
|
||||
UpdateControls();
|
||||
|
@ -297,9 +297,9 @@ void FIFOPlayerWindow::UpdateInfo()
|
|||
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 mem_bytes = 0;
|
||||
|
||||
|
@ -316,7 +316,7 @@ void FIFOPlayerWindow::UpdateInfo()
|
|||
return;
|
||||
}
|
||||
|
||||
if (Core::IsRunning() && FifoRecorder::GetInstance().IsRecording())
|
||||
if (Core::IsRunning() && m_fifo_recorder.IsRecording())
|
||||
{
|
||||
m_info_label->setText(tr("Recording..."));
|
||||
return;
|
||||
|
@ -376,7 +376,7 @@ void FIFOPlayerWindow::UpdateLimits()
|
|||
void FIFOPlayerWindow::UpdateControls()
|
||||
{
|
||||
bool running = Core::IsRunning();
|
||||
bool is_recording = FifoRecorder::GetInstance().IsRecording();
|
||||
bool is_recording = m_fifo_recorder.IsRecording();
|
||||
bool is_playing = m_fifo_player.IsPlaying();
|
||||
|
||||
m_frame_range_from->setEnabled(is_playing);
|
||||
|
@ -399,7 +399,7 @@ void FIFOPlayerWindow::UpdateControls()
|
|||
m_stop->setVisible(running && is_recording);
|
||||
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)
|
||||
|
|
|
@ -14,13 +14,15 @@ class QSpinBox;
|
|||
class QTabWidget;
|
||||
class ToolTipCheckBox;
|
||||
class FifoPlayer;
|
||||
class FifoRecorder;
|
||||
class FIFOAnalyzer;
|
||||
|
||||
class FIFOPlayerWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FIFOPlayerWindow(FifoPlayer& fifo_player, QWidget* parent = nullptr);
|
||||
explicit FIFOPlayerWindow(FifoPlayer& fifo_player, FifoRecorder& fifo_recorder,
|
||||
QWidget* parent = nullptr);
|
||||
~FIFOPlayerWindow();
|
||||
|
||||
signals:
|
||||
|
@ -51,6 +53,7 @@ private:
|
|||
bool eventFilter(QObject* object, QEvent* event) final override;
|
||||
|
||||
FifoPlayer& m_fifo_player;
|
||||
FifoRecorder& m_fifo_recorder;
|
||||
|
||||
QLabel* m_info_label;
|
||||
QPushButton* m_load;
|
||||
|
|
|
@ -1363,7 +1363,8 @@ void MainWindow::ShowFIFOPlayer()
|
|||
{
|
||||
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,
|
||||
[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);
|
||||
|
||||
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();
|
||||
|
||||
|
@ -624,7 +624,10 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, XFStateManager&
|
|||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
// process them.
|
||||
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.
|
||||
if (OpcodeDecoder::g_record_fifo_data && !texture_info.IsFromTmem())
|
||||
{
|
||||
FifoRecorder::GetInstance().UseMemory(texture_info.GetRawAddress(),
|
||||
texture_info.GetFullLevelSize(),
|
||||
MemoryUpdate::Type::TextureMap);
|
||||
Core::System::GetInstance().GetFifoRecorder().UseMemory(texture_info.GetRawAddress(),
|
||||
texture_info.GetFullLevelSize(),
|
||||
MemoryUpdate::Type::TextureMap);
|
||||
}
|
||||
|
||||
// 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;
|
||||
for (u32 i = 0; i < num_blocks_y; i++)
|
||||
{
|
||||
FifoRecorder::GetInstance().UseMemory(address, bytes_per_row, MemoryUpdate::Type::TextureMap,
|
||||
true);
|
||||
Core::System::GetInstance().GetFifoRecorder().UseMemory(address, bytes_per_row,
|
||||
MemoryUpdate::Type::TextureMap, true);
|
||||
address += dstStride;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue