mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-11 12:45:05 +01:00
Merge pull request #4683 from wwylele/misc-global-clean
Misc global instance reference cleaup
This commit is contained in:
commit
9b07ff9681
@ -198,6 +198,8 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
|
||||
dsp_core = std::make_unique<AudioCore::DspHle>(*memory);
|
||||
}
|
||||
|
||||
memory->SetDSP(*dsp_core);
|
||||
|
||||
dsp_core->SetSink(Settings::values.sink_id, Settings::values.audio_device_id);
|
||||
dsp_core->EnableStretching(Settings::values.enable_audio_stretching);
|
||||
|
||||
|
@ -103,7 +103,7 @@ static u32 DecompressLZ11(const u8* in, u8* out) {
|
||||
|
||||
bool Module::LoadSharedFont() {
|
||||
u8 font_region_code;
|
||||
auto cfg = Service::CFG::GetModule(Core::System::GetInstance());
|
||||
auto cfg = Service::CFG::GetModule(system);
|
||||
ASSERT_MSG(cfg, "CFG Module missing!");
|
||||
switch (cfg->GetRegionValue()) {
|
||||
case 4: // CHN
|
||||
|
@ -394,7 +394,7 @@ void InstallInterfaces(Core::System& system) {
|
||||
auto& service_manager = system.ServiceManager();
|
||||
auto dsp = std::make_shared<DSP_DSP>(system);
|
||||
dsp->InstallAsService(service_manager);
|
||||
Core::DSP().SetServiceToInterrupt(std::move(dsp));
|
||||
system.DSP().SetServiceToInterrupt(std::move(dsp));
|
||||
}
|
||||
|
||||
} // namespace Service::DSP
|
||||
|
@ -64,7 +64,7 @@ enum class ResponseID : u8 {
|
||||
ReadCalibrationData = 0x11,
|
||||
};
|
||||
|
||||
ExtraHID::ExtraHID(SendFunc send_func) : IRDevice(send_func) {
|
||||
ExtraHID::ExtraHID(SendFunc send_func, Core::Timing& timing) : IRDevice(send_func), timing(timing) {
|
||||
LoadInputDevices();
|
||||
|
||||
// The data below was retrieved from a New 3DS
|
||||
@ -145,11 +145,11 @@ ExtraHID::ExtraHID(SendFunc send_func) : IRDevice(send_func) {
|
||||
0x65,
|
||||
}};
|
||||
|
||||
hid_polling_callback_id = Core::System::GetInstance().CoreTiming().RegisterEvent(
|
||||
"ExtraHID::SendHIDStatus", [this](u64, s64 cycles_late) {
|
||||
hid_polling_callback_id =
|
||||
timing.RegisterEvent("ExtraHID::SendHIDStatus", [this](u64, s64 cycles_late) {
|
||||
SendHIDStatus();
|
||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(
|
||||
msToCycles(hid_period) - cycles_late, hid_polling_callback_id);
|
||||
this->timing.ScheduleEvent(msToCycles(hid_period) - cycles_late,
|
||||
hid_polling_callback_id);
|
||||
});
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ ExtraHID::~ExtraHID() {
|
||||
void ExtraHID::OnConnect() {}
|
||||
|
||||
void ExtraHID::OnDisconnect() {
|
||||
Core::System::GetInstance().CoreTiming().UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
timing.UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
}
|
||||
|
||||
void ExtraHID::HandleConfigureHIDPollingRequest(const std::vector<u8>& request) {
|
||||
@ -171,10 +171,9 @@ void ExtraHID::HandleConfigureHIDPollingRequest(const std::vector<u8>& request)
|
||||
}
|
||||
|
||||
// Change HID input polling interval
|
||||
Core::System::GetInstance().CoreTiming().UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
timing.UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
hid_period = request[1];
|
||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(msToCycles(hid_period),
|
||||
hid_polling_callback_id);
|
||||
timing.ScheduleEvent(msToCycles(hid_period), hid_polling_callback_id);
|
||||
}
|
||||
|
||||
void ExtraHID::HandleReadCalibrationDataRequest(const std::vector<u8>& request_buf) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
namespace Core {
|
||||
struct TimingEventType;
|
||||
class Timing;
|
||||
} // namespace Core
|
||||
|
||||
namespace Service::IR {
|
||||
@ -40,7 +41,7 @@ static_assert(sizeof(ExtraHIDResponse) == 6, "HID status response has wrong size
|
||||
*/
|
||||
class ExtraHID final : public IRDevice {
|
||||
public:
|
||||
explicit ExtraHID(SendFunc send_func);
|
||||
explicit ExtraHID(SendFunc send_func, Core::Timing& timing);
|
||||
~ExtraHID();
|
||||
|
||||
void OnConnect() override;
|
||||
@ -56,6 +57,7 @@ private:
|
||||
void HandleReadCalibrationDataRequest(const std::vector<u8>& request);
|
||||
void LoadInputDevices();
|
||||
|
||||
Core::Timing& timing;
|
||||
u8 hid_period;
|
||||
Core::TimingEventType* hid_polling_callback_id;
|
||||
std::array<u8, 0x40> calibration_data;
|
||||
|
@ -418,8 +418,8 @@ IR_USER::IR_USER(Core::System& system) : ServiceFramework("ir:USER", 1) {
|
||||
send_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:SendEvent");
|
||||
receive_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:ReceiveEvent");
|
||||
|
||||
extra_hid =
|
||||
std::make_unique<ExtraHID>([this](const std::vector<u8>& data) { PutToReceive(data); });
|
||||
extra_hid = std::make_unique<ExtraHID>(
|
||||
[this](const std::vector<u8>& data) { PutToReceive(data); }, system.CoreTiming());
|
||||
}
|
||||
|
||||
IR_USER::~IR_USER() {
|
||||
|
@ -507,7 +507,7 @@ void Y2R_U::StartConversion(Kernel::HLERequestContext& ctx) {
|
||||
Memory::RasterizerFlushVirtualRegion(conversion.dst.address, total_output_size,
|
||||
Memory::FlushMode::FlushAndInvalidate);
|
||||
|
||||
HW::Y2R::PerformConversion(conversion);
|
||||
HW::Y2R::PerformConversion(system.Memory(), conversion);
|
||||
|
||||
completion_event->Signal();
|
||||
|
||||
@ -632,7 +632,7 @@ void Y2R_U::GetPackageParameter(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Y2R, "called");
|
||||
}
|
||||
|
||||
Y2R_U::Y2R_U(Core::System& system) : ServiceFramework("y2r:u", 1) {
|
||||
Y2R_U::Y2R_U(Core::System& system) : ServiceFramework("y2r:u", 1), system(system) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0x00010040, &Y2R_U::SetInputFormat, "SetInputFormat"},
|
||||
{0x00020000, &Y2R_U::GetInputFormat, "GetInputFormat"},
|
||||
|
@ -294,6 +294,8 @@ private:
|
||||
void DriverFinalize(Kernel::HLERequestContext& ctx);
|
||||
void GetPackageParameter(Kernel::HLERequestContext& ctx);
|
||||
|
||||
Core::System& system;
|
||||
|
||||
Kernel::SharedPtr<Kernel::Event> completion_event;
|
||||
ConversionConfiguration conversion{};
|
||||
DitheringWeightParams dithering_weight_params{};
|
||||
|
@ -79,8 +79,9 @@ static void ConvertYUVToRGB(InputFormat input_format, const u8* input_Y, const u
|
||||
/// Simulates an incoming CDMA transfer. The N parameter is used to automatically convert 16-bit
|
||||
/// formats to 8-bit.
|
||||
template <std::size_t N>
|
||||
static void ReceiveData(u8* output, ConversionBuffer& buf, std::size_t amount_of_data) {
|
||||
const u8* input = Core::System::GetInstance().Memory().GetPointer(buf.address);
|
||||
static void ReceiveData(Memory::MemorySystem& memory, u8* output, ConversionBuffer& buf,
|
||||
std::size_t amount_of_data) {
|
||||
const u8* input = memory.GetPointer(buf.address);
|
||||
|
||||
std::size_t output_unit = buf.transfer_unit / N;
|
||||
ASSERT(amount_of_data % output_unit == 0);
|
||||
@ -101,10 +102,10 @@ static void ReceiveData(u8* output, ConversionBuffer& buf, std::size_t amount_of
|
||||
|
||||
/// Convert intermediate RGB32 format to the final output format while simulating an outgoing CDMA
|
||||
/// transfer.
|
||||
static void SendData(const u32* input, ConversionBuffer& buf, int amount_of_data,
|
||||
OutputFormat output_format, u8 alpha) {
|
||||
static void SendData(Memory::MemorySystem& memory, const u32* input, ConversionBuffer& buf,
|
||||
int amount_of_data, OutputFormat output_format, u8 alpha) {
|
||||
|
||||
u8* output = Core::System::GetInstance().Memory().GetPointer(buf.address);
|
||||
u8* output = memory.GetPointer(buf.address);
|
||||
|
||||
while (amount_of_data > 0) {
|
||||
u8* unit_end = output + buf.transfer_unit;
|
||||
@ -259,7 +260,7 @@ static void WriteTileToOutput(u32* output, const ImageTile& tile, int height, in
|
||||
* Hardware behaves strangely (doesn't fire the completion interrupt, for example) in these cases,
|
||||
* so they are believed to be invalid configurations anyway.
|
||||
*/
|
||||
void PerformConversion(ConversionConfiguration& cvt) {
|
||||
void PerformConversion(Memory::MemorySystem& memory, ConversionConfiguration& cvt) {
|
||||
ASSERT(cvt.input_line_width % 8 == 0);
|
||||
ASSERT(cvt.block_alignment != BlockAlignment::Block8x8 || cvt.input_lines % 8 == 0);
|
||||
// Tiles per row
|
||||
@ -296,29 +297,29 @@ void PerformConversion(ConversionConfiguration& cvt) {
|
||||
|
||||
switch (cvt.input_format) {
|
||||
case InputFormat::YUV422_Indiv8:
|
||||
ReceiveData<1>(input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<1>(input_U, cvt.src_U, row_data_size / 2);
|
||||
ReceiveData<1>(input_V, cvt.src_V, row_data_size / 2);
|
||||
ReceiveData<1>(memory, input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<1>(memory, input_U, cvt.src_U, row_data_size / 2);
|
||||
ReceiveData<1>(memory, input_V, cvt.src_V, row_data_size / 2);
|
||||
break;
|
||||
case InputFormat::YUV420_Indiv8:
|
||||
ReceiveData<1>(input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<1>(input_U, cvt.src_U, row_data_size / 4);
|
||||
ReceiveData<1>(input_V, cvt.src_V, row_data_size / 4);
|
||||
ReceiveData<1>(memory, input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<1>(memory, input_U, cvt.src_U, row_data_size / 4);
|
||||
ReceiveData<1>(memory, input_V, cvt.src_V, row_data_size / 4);
|
||||
break;
|
||||
case InputFormat::YUV422_Indiv16:
|
||||
ReceiveData<2>(input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<2>(input_U, cvt.src_U, row_data_size / 2);
|
||||
ReceiveData<2>(input_V, cvt.src_V, row_data_size / 2);
|
||||
ReceiveData<2>(memory, input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<2>(memory, input_U, cvt.src_U, row_data_size / 2);
|
||||
ReceiveData<2>(memory, input_V, cvt.src_V, row_data_size / 2);
|
||||
break;
|
||||
case InputFormat::YUV420_Indiv16:
|
||||
ReceiveData<2>(input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<2>(input_U, cvt.src_U, row_data_size / 4);
|
||||
ReceiveData<2>(input_V, cvt.src_V, row_data_size / 4);
|
||||
ReceiveData<2>(memory, input_Y, cvt.src_Y, row_data_size);
|
||||
ReceiveData<2>(memory, input_U, cvt.src_U, row_data_size / 4);
|
||||
ReceiveData<2>(memory, input_V, cvt.src_V, row_data_size / 4);
|
||||
break;
|
||||
case InputFormat::YUYV422_Interleaved:
|
||||
input_U = nullptr;
|
||||
input_V = nullptr;
|
||||
ReceiveData<1>(input_Y, cvt.src_YUYV, row_data_size * 2);
|
||||
ReceiveData<1>(memory, input_Y, cvt.src_YUYV, row_data_size * 2);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -372,7 +373,7 @@ void PerformConversion(ConversionConfiguration& cvt) {
|
||||
|
||||
// Note(yuriks): If additional optimization is required, output_format can be moved to a
|
||||
// template parameter, so that its dispatch can be moved to outside the inner loop.
|
||||
SendData(reinterpret_cast<u32*>(data_buffer.get()), cvt.dst, (int)row_data_size,
|
||||
SendData(memory, reinterpret_cast<u32*>(data_buffer.get()), cvt.dst, (int)row_data_size,
|
||||
cvt.output_format, (u8)cvt.alpha);
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Memory {
|
||||
class MemorySystem;
|
||||
}
|
||||
|
||||
namespace Service::Y2R {
|
||||
struct ConversionConfiguration;
|
||||
} // namespace Service::Y2R
|
||||
|
||||
namespace HW::Y2R {
|
||||
void PerformConversion(Service::Y2R::ConversionConfiguration& cvt);
|
||||
void PerformConversion(Memory::MemorySystem& memory, Service::Y2R::ConversionConfiguration& cvt);
|
||||
} // namespace HW::Y2R
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
std::vector<PageTable*> page_table_list;
|
||||
|
||||
ARM_Interface* cpu = nullptr;
|
||||
AudioCore::DspInterface* dsp = nullptr;
|
||||
};
|
||||
|
||||
MemorySystem::MemorySystem() : impl(std::make_unique<Impl>()) {}
|
||||
@ -325,7 +326,7 @@ u8* MemorySystem::GetPhysicalPointer(PAddr address) {
|
||||
target_pointer = impl->vram.get() + offset_into_region;
|
||||
break;
|
||||
case DSP_RAM_PADDR:
|
||||
target_pointer = Core::DSP().GetDspMemory().data() + offset_into_region;
|
||||
target_pointer = impl->dsp->GetDspMemory().data() + offset_into_region;
|
||||
break;
|
||||
case FCRAM_PADDR:
|
||||
target_pointer = impl->fcram.get() + offset_into_region;
|
||||
@ -808,4 +809,8 @@ u8* MemorySystem::GetFCRAMPointer(u32 offset) {
|
||||
return impl->fcram.get() + offset;
|
||||
}
|
||||
|
||||
void MemorySystem::SetDSP(AudioCore::DspInterface& dsp) {
|
||||
impl->dsp = &dsp;
|
||||
}
|
||||
|
||||
} // namespace Memory
|
||||
|
@ -18,6 +18,10 @@ namespace Kernel {
|
||||
class Process;
|
||||
}
|
||||
|
||||
namespace AudioCore {
|
||||
class DspInterface;
|
||||
}
|
||||
|
||||
namespace Memory {
|
||||
|
||||
// Are defined in a system header
|
||||
@ -292,6 +296,8 @@ public:
|
||||
/// Unregisters page table for rasterizer cache marking
|
||||
void UnregisterPageTable(PageTable* page_table);
|
||||
|
||||
void SetDSP(AudioCore::DspInterface& dsp);
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
T Read(const VAddr vaddr);
|
||||
|
Loading…
Reference in New Issue
Block a user