mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
Merge pull request #2972 from lioncash/system
{bcat, gpu, nvflinger}: Remove trivial usages of the global system accessor
This commit is contained in:
commit
2299950de1
@ -1140,8 +1140,9 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
|
|||||||
LOG_DEBUG(Service_AM, "called, kind={:08X}", static_cast<u8>(kind));
|
LOG_DEBUG(Service_AM, "called, kind={:08X}", static_cast<u8>(kind));
|
||||||
|
|
||||||
if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) {
|
if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) {
|
||||||
const auto backend = BCAT::CreateBackendFromSettings(
|
const auto backend = BCAT::CreateBackendFromSettings(system, [this](u64 tid) {
|
||||||
[this](u64 tid) { return system.GetFileSystemController().GetBCATDirectory(tid); });
|
return system.GetFileSystemController().GetBCATDirectory(tid);
|
||||||
|
});
|
||||||
const auto build_id_full = system.GetCurrentProcessBuildID();
|
const auto build_id_full = system.GetCurrentProcessBuildID();
|
||||||
u64 build_id{};
|
u64 build_id{};
|
||||||
std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
|
std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
namespace Service::BCAT {
|
namespace Service::BCAT {
|
||||||
|
|
||||||
ProgressServiceBackend::ProgressServiceBackend(std::string_view event_name) {
|
ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel,
|
||||||
auto& kernel{Core::System::GetInstance().Kernel()};
|
std::string_view event_name) {
|
||||||
event = Kernel::WritableEvent::CreateEventPair(
|
event = Kernel::WritableEvent::CreateEventPair(
|
||||||
kernel, Kernel::ResetType::Automatic,
|
kernel, Kernel::ResetType::Automatic,
|
||||||
std::string("ProgressServiceBackend:UpdateEvent:").append(event_name));
|
std::string("ProgressServiceBackend:UpdateEvent:").append(event_name));
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
#include "core/hle/kernel/writable_event.h"
|
#include "core/hle/kernel/writable_event.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class KernelCore;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::BCAT {
|
namespace Service::BCAT {
|
||||||
|
|
||||||
struct DeliveryCacheProgressImpl;
|
struct DeliveryCacheProgressImpl;
|
||||||
@ -88,7 +96,7 @@ public:
|
|||||||
void FinishDownload(ResultCode result);
|
void FinishDownload(ResultCode result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ProgressServiceBackend(std::string_view event_name);
|
explicit ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name);
|
||||||
|
|
||||||
Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent() const;
|
Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent() const;
|
||||||
DeliveryCacheProgressImpl& GetImpl();
|
DeliveryCacheProgressImpl& GetImpl();
|
||||||
@ -145,6 +153,6 @@ public:
|
|||||||
std::optional<std::vector<u8>> GetLaunchParameter(TitleIDVersion title) override;
|
std::optional<std::vector<u8>> GetLaunchParameter(TitleIDVersion title) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter);
|
std::unique_ptr<Backend> CreateBackendFromSettings(Core::System& system, DirectoryGetter getter);
|
||||||
|
|
||||||
} // namespace Service::BCAT
|
} // namespace Service::BCAT
|
||||||
|
@ -104,14 +104,15 @@ std::string GetZIPFilePath(u64 title_id) {
|
|||||||
|
|
||||||
// If the error is something the user should know about (build ID mismatch, bad client version),
|
// If the error is something the user should know about (build ID mismatch, bad client version),
|
||||||
// display an error.
|
// display an error.
|
||||||
void HandleDownloadDisplayResult(DownloadResult res) {
|
void HandleDownloadDisplayResult(const AM::Applets::AppletManager& applet_manager,
|
||||||
|
DownloadResult res) {
|
||||||
if (res == DownloadResult::Success || res == DownloadResult::NoResponse ||
|
if (res == DownloadResult::Success || res == DownloadResult::NoResponse ||
|
||||||
res == DownloadResult::GeneralWebError || res == DownloadResult::GeneralFSError ||
|
res == DownloadResult::GeneralWebError || res == DownloadResult::GeneralFSError ||
|
||||||
res == DownloadResult::NoMatchTitleId || res == DownloadResult::InvalidContentType) {
|
res == DownloadResult::NoMatchTitleId || res == DownloadResult::InvalidContentType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& frontend{Core::System::GetInstance().GetAppletManager().GetAppletFrontendSet()};
|
const auto& frontend{applet_manager.GetAppletFrontendSet()};
|
||||||
frontend.error->ShowCustomErrorText(
|
frontend.error->ShowCustomErrorText(
|
||||||
ResultCode(-1), "There was an error while attempting to use Boxcat.",
|
ResultCode(-1), "There was an error while attempting to use Boxcat.",
|
||||||
DOWNLOAD_RESULT_LOG_MESSAGES[static_cast<std::size_t>(res)], [] {});
|
DOWNLOAD_RESULT_LOG_MESSAGES[static_cast<std::size_t>(res)], [] {});
|
||||||
@ -264,12 +265,13 @@ private:
|
|||||||
u64 build_id;
|
u64 build_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
Boxcat::Boxcat(DirectoryGetter getter) : Backend(std::move(getter)) {}
|
Boxcat::Boxcat(AM::Applets::AppletManager& applet_manager_, DirectoryGetter getter)
|
||||||
|
: Backend(std::move(getter)), applet_manager{applet_manager_} {}
|
||||||
|
|
||||||
Boxcat::~Boxcat() = default;
|
Boxcat::~Boxcat() = default;
|
||||||
|
|
||||||
void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title,
|
void SynchronizeInternal(AM::Applets::AppletManager& applet_manager, DirectoryGetter dir_getter,
|
||||||
ProgressServiceBackend& progress,
|
TitleIDVersion title, ProgressServiceBackend& progress,
|
||||||
std::optional<std::string> dir_name = {}) {
|
std::optional<std::string> dir_name = {}) {
|
||||||
progress.SetNeedHLELock(true);
|
progress.SetNeedHLELock(true);
|
||||||
|
|
||||||
@ -295,7 +297,7 @@ void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title,
|
|||||||
FileUtil::Delete(zip_path);
|
FileUtil::Delete(zip_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleDownloadDisplayResult(res);
|
HandleDownloadDisplayResult(applet_manager, res);
|
||||||
progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE);
|
progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -364,17 +366,24 @@ void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title,
|
|||||||
|
|
||||||
bool Boxcat::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) {
|
bool Boxcat::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) {
|
||||||
is_syncing.exchange(true);
|
is_syncing.exchange(true);
|
||||||
std::thread([this, title, &progress] { SynchronizeInternal(dir_getter, title, progress); })
|
|
||||||
|
std::thread([this, title, &progress] {
|
||||||
|
SynchronizeInternal(applet_manager, dir_getter, title, progress);
|
||||||
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Boxcat::SynchronizeDirectory(TitleIDVersion title, std::string name,
|
bool Boxcat::SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||||
ProgressServiceBackend& progress) {
|
ProgressServiceBackend& progress) {
|
||||||
is_syncing.exchange(true);
|
is_syncing.exchange(true);
|
||||||
std::thread(
|
|
||||||
[this, title, name, &progress] { SynchronizeInternal(dir_getter, title, progress, name); })
|
std::thread([this, title, name, &progress] {
|
||||||
|
SynchronizeInternal(applet_manager, dir_getter, title, progress, name);
|
||||||
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +429,7 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title)
|
|||||||
FileUtil::Delete(path);
|
FileUtil::Delete(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleDownloadDisplayResult(res);
|
HandleDownloadDisplayResult(applet_manager, res);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include "core/hle/service/bcat/backend/backend.h"
|
#include "core/hle/service/bcat/backend/backend.h"
|
||||||
|
|
||||||
|
namespace Service::AM::Applets {
|
||||||
|
class AppletManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::BCAT {
|
namespace Service::BCAT {
|
||||||
|
|
||||||
struct EventStatus {
|
struct EventStatus {
|
||||||
@ -20,12 +24,13 @@ struct EventStatus {
|
|||||||
/// Boxcat is yuzu's custom backend implementation of Nintendo's BCAT service. It is free to use and
|
/// Boxcat is yuzu's custom backend implementation of Nintendo's BCAT service. It is free to use and
|
||||||
/// doesn't require a switch or nintendo account. The content is controlled by the yuzu team.
|
/// doesn't require a switch or nintendo account. The content is controlled by the yuzu team.
|
||||||
class Boxcat final : public Backend {
|
class Boxcat final : public Backend {
|
||||||
friend void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title,
|
friend void SynchronizeInternal(AM::Applets::AppletManager& applet_manager,
|
||||||
|
DirectoryGetter dir_getter, TitleIDVersion title,
|
||||||
ProgressServiceBackend& progress,
|
ProgressServiceBackend& progress,
|
||||||
std::optional<std::string> dir_name);
|
std::optional<std::string> dir_name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Boxcat(DirectoryGetter getter);
|
explicit Boxcat(AM::Applets::AppletManager& applet_manager_, DirectoryGetter getter);
|
||||||
~Boxcat() override;
|
~Boxcat() override;
|
||||||
|
|
||||||
bool Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) override;
|
bool Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) override;
|
||||||
@ -53,6 +58,7 @@ private:
|
|||||||
|
|
||||||
class Client;
|
class Client;
|
||||||
std::unique_ptr<Client> client;
|
std::unique_ptr<Client> client;
|
||||||
|
AM::Applets::AppletManager& applet_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::BCAT
|
} // namespace Service::BCAT
|
||||||
|
@ -125,7 +125,11 @@ private:
|
|||||||
class IBcatService final : public ServiceFramework<IBcatService> {
|
class IBcatService final : public ServiceFramework<IBcatService> {
|
||||||
public:
|
public:
|
||||||
explicit IBcatService(Core::System& system_, Backend& backend_)
|
explicit IBcatService(Core::System& system_, Backend& backend_)
|
||||||
: ServiceFramework("IBcatService"), system{system_}, backend{backend_} {
|
: ServiceFramework("IBcatService"), system{system_}, backend{backend_},
|
||||||
|
progress{{
|
||||||
|
ProgressServiceBackend{system_.Kernel(), "Normal"},
|
||||||
|
ProgressServiceBackend{system_.Kernel(), "Directory"},
|
||||||
|
}} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{10100, &IBcatService::RequestSyncDeliveryCache, "RequestSyncDeliveryCache"},
|
{10100, &IBcatService::RequestSyncDeliveryCache, "RequestSyncDeliveryCache"},
|
||||||
@ -249,10 +253,7 @@ private:
|
|||||||
Core::System& system;
|
Core::System& system;
|
||||||
Backend& backend;
|
Backend& backend;
|
||||||
|
|
||||||
std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress{
|
std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress;
|
||||||
ProgressServiceBackend{"Normal"},
|
|
||||||
ProgressServiceBackend{"Directory"},
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) {
|
||||||
@ -557,12 +558,12 @@ void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(
|
|||||||
rb.PushIpcInterface<IDeliveryCacheStorageService>(fsc.GetBCATDirectory(title_id));
|
rb.PushIpcInterface<IDeliveryCacheStorageService>(fsc.GetBCATDirectory(title_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter) {
|
std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System& system,
|
||||||
const auto backend = Settings::values.bcat_backend;
|
DirectoryGetter getter) {
|
||||||
|
|
||||||
#ifdef YUZU_ENABLE_BOXCAT
|
#ifdef YUZU_ENABLE_BOXCAT
|
||||||
if (backend == "boxcat")
|
if (Settings::values.bcat_backend == "boxcat") {
|
||||||
return std::make_unique<Boxcat>(std::move(getter));
|
return std::make_unique<Boxcat>(system.GetAppletManager(), std::move(getter));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return std::make_unique<NullBackend>(std::move(getter));
|
return std::make_unique<NullBackend>(std::move(getter));
|
||||||
@ -571,7 +572,8 @@ std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter) {
|
|||||||
Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_,
|
Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_,
|
||||||
FileSystem::FileSystemController& fsc_, const char* name)
|
FileSystem::FileSystemController& fsc_, const char* name)
|
||||||
: ServiceFramework(name), fsc{fsc_}, module{std::move(module_)},
|
: ServiceFramework(name), fsc{fsc_}, module{std::move(module_)},
|
||||||
backend{CreateBackendFromSettings([&fsc_](u64 tid) { return fsc_.GetBCATDirectory(tid); })},
|
backend{CreateBackendFromSettings(system_,
|
||||||
|
[&fsc_](u64 tid) { return fsc_.GetBCATDirectory(tid); })},
|
||||||
system{system_} {}
|
system{system_} {}
|
||||||
|
|
||||||
Module::Interface::~Interface() = default;
|
Module::Interface::~Interface() = default;
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
namespace Service::NVFlinger {
|
namespace Service::NVFlinger {
|
||||||
|
|
||||||
BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) {
|
BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id)
|
||||||
auto& kernel = Core::System::GetInstance().Kernel();
|
: id(id), layer_id(layer_id) {
|
||||||
buffer_wait_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
|
buffer_wait_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
|
||||||
"BufferQueue NativeHandle");
|
"BufferQueue NativeHandle");
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
#include "core/hle/kernel/writable_event.h"
|
#include "core/hle/kernel/writable_event.h"
|
||||||
#include "core/hle/service/nvdrv/nvdata.h"
|
#include "core/hle/service/nvdrv/nvdata.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class KernelCore;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::NVFlinger {
|
namespace Service::NVFlinger {
|
||||||
|
|
||||||
struct IGBPBuffer {
|
struct IGBPBuffer {
|
||||||
@ -44,7 +48,7 @@ public:
|
|||||||
NativeWindowFormat = 2,
|
NativeWindowFormat = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
BufferQueue(u32 id, u64 layer_id);
|
explicit BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id);
|
||||||
~BufferQueue();
|
~BufferQueue();
|
||||||
|
|
||||||
enum class BufferTransformFlags : u32 {
|
enum class BufferTransformFlags : u32 {
|
||||||
|
@ -83,7 +83,7 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) {
|
|||||||
|
|
||||||
const u64 layer_id = next_layer_id++;
|
const u64 layer_id = next_layer_id++;
|
||||||
const u32 buffer_queue_id = next_buffer_queue_id++;
|
const u32 buffer_queue_id = next_buffer_queue_id++;
|
||||||
buffer_queues.emplace_back(buffer_queue_id, layer_id);
|
buffer_queues.emplace_back(system.Kernel(), buffer_queue_id, layer_id);
|
||||||
display->CreateLayer(layer_id, buffer_queues.back());
|
display->CreateLayer(layer_id, buffer_queues.back());
|
||||||
return layer_id;
|
return layer_id;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ void GPU::ProcessSemaphoreTriggerMethod() {
|
|||||||
block.sequence = regs.semaphore_sequence;
|
block.sequence = regs.semaphore_sequence;
|
||||||
// TODO(Kmather73): Generate a real GPU timestamp and write it here instead of
|
// TODO(Kmather73): Generate a real GPU timestamp and write it here instead of
|
||||||
// CoreTiming
|
// CoreTiming
|
||||||
block.timestamp = Core::System::GetInstance().CoreTiming().GetTicks();
|
block.timestamp = system.CoreTiming().GetTicks();
|
||||||
memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block,
|
memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block,
|
||||||
sizeof(block));
|
sizeof(block));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user