mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-12 06:39:26 +00:00
[video_core, hle] remove redundant parent references in system structs (#3908)
reworked a bit to remove references of parent objects and instead pass as arguments to methods to prevent useless reloads Signed-off-by: lizzie <lizzie@eden-emu.dev> Co-authored-by: maufeat <sahyno1996@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3908 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
namespace Service::BCAT {
|
||||
|
||||
ProgressServiceBackend::ProgressServiceBackend(Core::System& system, std::string_view event_name)
|
||||
: service_context{system, "ProgressServiceBackend"} {
|
||||
update_event = service_context.CreateEvent("ProgressServiceBackend:UpdateEvent:" +
|
||||
std::string(event_name));
|
||||
: service_context{system, "ProgressServiceBackend"}
|
||||
{
|
||||
update_event = service_context.CreateEvent("ProgressServiceBackend:UpdateEvent:" + std::string(event_name));
|
||||
}
|
||||
|
||||
ProgressServiceBackend::~ProgressServiceBackend() {
|
||||
@@ -30,103 +30,90 @@ DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() {
|
||||
return impl;
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::SetTotalSize(u64 size) {
|
||||
void ProgressServiceBackend::SetTotalSize(Kernel::KernelCore& kernel, u64 size) {
|
||||
impl.total_bytes = size;
|
||||
SignalUpdate();
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::StartConnecting() {
|
||||
void ProgressServiceBackend::StartConnecting(Kernel::KernelCore& kernel) {
|
||||
impl.status = DeliveryCacheProgressStatus::Connecting;
|
||||
SignalUpdate();
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::StartProcessingDataList() {
|
||||
void ProgressServiceBackend::StartProcessingDataList(Kernel::KernelCore& kernel) {
|
||||
impl.status = DeliveryCacheProgressStatus::ProcessingDataList;
|
||||
SignalUpdate();
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::StartDownloadingFile(std::string_view dir_name,
|
||||
std::string_view file_name, u64 file_size) {
|
||||
void ProgressServiceBackend::StartDownloadingFile(Kernel::KernelCore& kernel, std::string_view dir_name, std::string_view file_name, u64 file_size) {
|
||||
impl.status = DeliveryCacheProgressStatus::Downloading;
|
||||
impl.current_downloaded_bytes = 0;
|
||||
impl.current_total_bytes = file_size;
|
||||
std::memcpy(impl.current_directory.data(), dir_name.data(),
|
||||
std::min<u64>(dir_name.size(), 0x31ull));
|
||||
std::memcpy(impl.current_file.data(), file_name.data(),
|
||||
std::min<u64>(file_name.size(), 0x31ull));
|
||||
SignalUpdate();
|
||||
std::memcpy(impl.current_directory.data(), dir_name.data(), std::min<u64>(dir_name.size(), 0x31ull));
|
||||
std::memcpy(impl.current_file.data(), file_name.data(), std::min<u64>(file_name.size(), 0x31ull));
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::UpdateFileProgress(u64 downloaded) {
|
||||
void ProgressServiceBackend::UpdateFileProgress(Kernel::KernelCore& kernel, u64 downloaded) {
|
||||
impl.current_downloaded_bytes = downloaded;
|
||||
SignalUpdate();
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::FinishDownloadingFile() {
|
||||
void ProgressServiceBackend::FinishDownloadingFile(Kernel::KernelCore& kernel) {
|
||||
impl.total_downloaded_bytes += impl.current_total_bytes;
|
||||
SignalUpdate();
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::CommitDirectory(std::string_view dir_name) {
|
||||
void ProgressServiceBackend::CommitDirectory(Kernel::KernelCore& kernel, std::string_view dir_name) {
|
||||
impl.status = DeliveryCacheProgressStatus::Committing;
|
||||
impl.current_file.fill(0);
|
||||
impl.current_downloaded_bytes = 0;
|
||||
impl.current_total_bytes = 0;
|
||||
std::memcpy(impl.current_directory.data(), dir_name.data(),
|
||||
std::min<u64>(dir_name.size(), 0x31ull));
|
||||
SignalUpdate();
|
||||
std::memcpy(impl.current_directory.data(), dir_name.data(), std::min<u64>(dir_name.size(), 0x31ull));
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::FinishDownload(Result result) {
|
||||
void ProgressServiceBackend::FinishDownload(Kernel::KernelCore& kernel, Result result) {
|
||||
impl.total_downloaded_bytes = impl.total_bytes;
|
||||
impl.status = DeliveryCacheProgressStatus::Done;
|
||||
impl.result = result;
|
||||
SignalUpdate();
|
||||
SignalUpdate(kernel);
|
||||
}
|
||||
|
||||
void ProgressServiceBackend::SignalUpdate() {
|
||||
update_event->Signal();
|
||||
void ProgressServiceBackend::SignalUpdate(Kernel::KernelCore& kernel) {
|
||||
update_event->Signal(kernel);
|
||||
}
|
||||
|
||||
BcatBackend::BcatBackend(DirectoryGetter getter) : dir_getter(std::move(getter)) {}
|
||||
|
||||
BcatBackend::~BcatBackend() = default;
|
||||
|
||||
NullBcatBackend::NullBcatBackend(DirectoryGetter getter) : BcatBackend(std::move(getter)) {}
|
||||
|
||||
NullBcatBackend::~NullBcatBackend() = default;
|
||||
|
||||
bool NullBcatBackend::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id,
|
||||
title.build_id);
|
||||
|
||||
progress.FinishDownload(ResultSuccess);
|
||||
bool NullBcatBackend::Synchronize(Kernel::KernelCore& kernel, TitleIDVersion title, ProgressServiceBackend& progress) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id, title.build_id);
|
||||
progress.FinishDownload(kernel, ResultSuccess);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NullBcatBackend::SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||
ProgressServiceBackend& progress) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}, name={}", title.title_id,
|
||||
title.build_id, name);
|
||||
|
||||
progress.FinishDownload(ResultSuccess);
|
||||
bool NullBcatBackend::SynchronizeDirectory(Kernel::KernelCore& kernel, TitleIDVersion title, std::string name, ProgressServiceBackend& progress) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}, name={}", title.title_id, title.build_id, name);
|
||||
progress.FinishDownload(kernel, ResultSuccess);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NullBcatBackend::Clear(u64 title_id) {
|
||||
bool NullBcatBackend::Clear(Kernel::KernelCore& kernel, u64 title_id) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}", title_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NullBcatBackend::SetPassphrase(u64 title_id, const Passphrase& passphrase) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id,
|
||||
Common::HexToString(passphrase));
|
||||
void NullBcatBackend::SetPassphrase(Kernel::KernelCore& kernel, u64 title_id, const Passphrase& passphrase) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id, Common::HexToString(passphrase));
|
||||
}
|
||||
|
||||
std::optional<std::vector<u8>> NullBcatBackend::GetLaunchParameter(TitleIDVersion title) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id,
|
||||
title.build_id);
|
||||
std::optional<std::vector<u8>> NullBcatBackend::GetLaunchParameter(Kernel::KernelCore& kernel, TitleIDVersion title) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, build_id={:016X}", title.title_id, title.build_id);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -34,26 +37,26 @@ public:
|
||||
~ProgressServiceBackend();
|
||||
|
||||
// Sets the number of bytes total in the entire download.
|
||||
void SetTotalSize(u64 size);
|
||||
void SetTotalSize(Kernel::KernelCore& kernel, u64 size);
|
||||
|
||||
// Notifies the application that the backend has started connecting to the server.
|
||||
void StartConnecting();
|
||||
void StartConnecting(Kernel::KernelCore& kernel);
|
||||
// Notifies the application that the backend has begun accumulating and processing metadata.
|
||||
void StartProcessingDataList();
|
||||
void StartProcessingDataList(Kernel::KernelCore& kernel);
|
||||
|
||||
// Notifies the application that a file is starting to be downloaded.
|
||||
void StartDownloadingFile(std::string_view dir_name, std::string_view file_name, u64 file_size);
|
||||
void StartDownloadingFile(Kernel::KernelCore& kernel, std::string_view dir_name, std::string_view file_name, u64 file_size);
|
||||
// Updates the progress of the current file to the size passed.
|
||||
void UpdateFileProgress(u64 downloaded);
|
||||
void UpdateFileProgress(Kernel::KernelCore& kernel, u64 downloaded);
|
||||
// Notifies the application that the current file has completed download.
|
||||
void FinishDownloadingFile();
|
||||
void FinishDownloadingFile(Kernel::KernelCore& kernel);
|
||||
|
||||
// Notifies the application that all files in this directory have completed and are being
|
||||
// finalized.
|
||||
void CommitDirectory(std::string_view dir_name);
|
||||
void CommitDirectory(Kernel::KernelCore& kernel, std::string_view dir_name);
|
||||
|
||||
// Notifies the application that the operation completed with result code result.
|
||||
void FinishDownload(Result result);
|
||||
void FinishDownload(Kernel::KernelCore& kernel, Result result);
|
||||
|
||||
private:
|
||||
explicit ProgressServiceBackend(Core::System& system, std::string_view event_name);
|
||||
@@ -61,7 +64,7 @@ private:
|
||||
Kernel::KReadableEvent& GetEvent();
|
||||
DeliveryCacheProgressImpl& GetImpl();
|
||||
|
||||
void SignalUpdate();
|
||||
void SignalUpdate(Kernel::KernelCore& kernel);
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
|
||||
@@ -74,25 +77,19 @@ class BcatBackend {
|
||||
public:
|
||||
explicit BcatBackend(DirectoryGetter getter);
|
||||
virtual ~BcatBackend();
|
||||
|
||||
// Called when the backend is needed to synchronize the data for the game with title ID and
|
||||
// version in title. A ProgressServiceBackend object is provided to alert the application of
|
||||
// status.
|
||||
virtual bool Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) = 0;
|
||||
virtual bool Synchronize(Kernel::KernelCore& kernel, TitleIDVersion title, ProgressServiceBackend& progress) = 0;
|
||||
// Very similar to Synchronize, but only for the directory provided. Backends should not alter
|
||||
// the data for any other directories.
|
||||
virtual bool SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||
ProgressServiceBackend& progress) = 0;
|
||||
|
||||
virtual bool SynchronizeDirectory(Kernel::KernelCore& kernel, TitleIDVersion title, std::string name, ProgressServiceBackend& progress) = 0;
|
||||
// Removes all cached data associated with title id provided.
|
||||
virtual bool Clear(u64 title_id) = 0;
|
||||
|
||||
virtual bool Clear(Kernel::KernelCore& kernel, u64 title_id) = 0;
|
||||
// Sets the BCAT Passphrase to be used with the associated title ID.
|
||||
virtual void SetPassphrase(u64 title_id, const Passphrase& passphrase) = 0;
|
||||
|
||||
virtual void SetPassphrase(Kernel::KernelCore& kernel, u64 title_id, const Passphrase& passphrase) = 0;
|
||||
// Gets the launch parameter used by AM associated with the title ID and version provided.
|
||||
virtual std::optional<std::vector<u8>> GetLaunchParameter(TitleIDVersion title) = 0;
|
||||
|
||||
virtual std::optional<std::vector<u8>> GetLaunchParameter(Kernel::KernelCore& kernel, TitleIDVersion title) = 0;
|
||||
protected:
|
||||
DirectoryGetter dir_getter;
|
||||
};
|
||||
@@ -103,18 +100,13 @@ public:
|
||||
explicit NullBcatBackend(DirectoryGetter getter);
|
||||
~NullBcatBackend() override;
|
||||
|
||||
bool Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) override;
|
||||
bool SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||
ProgressServiceBackend& progress) override;
|
||||
|
||||
bool Clear(u64 title_id) override;
|
||||
|
||||
void SetPassphrase(u64 title_id, const Passphrase& passphrase) override;
|
||||
|
||||
std::optional<std::vector<u8>> GetLaunchParameter(TitleIDVersion title) override;
|
||||
bool Synchronize(Kernel::KernelCore& kernel, TitleIDVersion title, ProgressServiceBackend& progress) override;
|
||||
bool SynchronizeDirectory(Kernel::KernelCore& kernel, TitleIDVersion title, std::string name, ProgressServiceBackend& progress) override;
|
||||
bool Clear(Kernel::KernelCore& kernel, u64 title_id) override;
|
||||
void SetPassphrase(Kernel::KernelCore& kernel, u64 title_id, const Passphrase& passphrase) override;
|
||||
std::optional<std::vector<u8>> GetLaunchParameter(Kernel::KernelCore& kernel, TitleIDVersion title) override;
|
||||
};
|
||||
|
||||
std::unique_ptr<BcatBackend> CreateBackendFromSettings(Core::System& system,
|
||||
DirectoryGetter getter);
|
||||
std::unique_ptr<BcatBackend> CreateBackendFromSettings(Core::System& system, DirectoryGetter getter);
|
||||
|
||||
} // namespace Service::BCAT
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
@@ -70,7 +70,7 @@ Result IBcatService::RequestSyncDeliveryCache(
|
||||
LOG_DEBUG(Service_BCAT, "called");
|
||||
|
||||
auto& progress_backend{GetProgressBackend(SyncType::Normal)};
|
||||
backend.Synchronize({system.GetApplicationProcessProgramID(),
|
||||
backend.Synchronize(system.Kernel(), {system.GetApplicationProcessProgramID(),
|
||||
GetCurrentBuildID(system.GetApplicationProcessBuildID())},
|
||||
GetProgressBackend(SyncType::Normal));
|
||||
|
||||
@@ -86,7 +86,7 @@ Result IBcatService::RequestSyncDeliveryCacheWithDirectoryName(
|
||||
LOG_DEBUG(Service_BCAT, "called, name={}", name);
|
||||
|
||||
auto& progress_backend{GetProgressBackend(SyncType::Directory)};
|
||||
backend.SynchronizeDirectory({system.GetApplicationProcessProgramID(),
|
||||
backend.SynchronizeDirectory(system.Kernel(), {system.GetApplicationProcessProgramID(),
|
||||
GetCurrentBuildID(system.GetApplicationProcessBuildID())},
|
||||
name, progress_backend);
|
||||
|
||||
@@ -107,7 +107,7 @@ Result IBcatService::SetPassphrase(u64 application_id,
|
||||
std::memcpy(passphrase.data(), passphrase_buffer.data(),
|
||||
(std::min)(passphrase.size(), passphrase_buffer.size()));
|
||||
|
||||
backend.SetPassphrase(application_id, passphrase);
|
||||
backend.SetPassphrase(system.Kernel(), application_id, passphrase);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ Result IBcatService::ClearDeliveryCacheStorage(u64 application_id) {
|
||||
LOG_DEBUG(Service_BCAT, "called, title_id={:016X}", application_id);
|
||||
|
||||
R_UNLESS(application_id != 0, ResultInvalidArgument);
|
||||
R_UNLESS(backend.Clear(application_id), FileSys::ResultPermissionDenied);
|
||||
R_UNLESS(backend.Clear(system.Kernel(), application_id), FileSys::ResultPermissionDenied);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user