From 39c8d18feba8eafcd43fbb55e73ae150a1947aad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 13 Oct 2020 08:10:50 -0400 Subject: core/CMakeLists: Make some warnings errors Makes our error coverage a little more consistent across the board by applying it to Linux side of things as well. This also makes it more consistent with the warning settings in other libraries in the project. This also updates httplib to 0.7.9, as there are several warning cleanups made that allow us to enable several warnings as errors. --- src/core/hle/service/vi/vi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 480d34725..d380c60fb 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -159,7 +159,7 @@ public: header.data_size = static_cast(write_index - sizeof(Header)); header.data_offset = sizeof(Header); header.objects_size = 4; - header.objects_offset = sizeof(Header) + header.data_size; + header.objects_offset = static_cast(sizeof(Header) + header.data_size); std::memcpy(buffer.data(), &header, sizeof(Header)); return buffer; -- cgit v1.2.3 From 1f186f34a29da8c4e39e3ad25fff1e4a39b33e85 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 12 Oct 2020 17:35:34 -0700 Subject: hle: service: vi: Implement BufferQueue::CancelBuffer. - This is used by Super Mario 3D All-Stars. --- src/core/hle/service/vi/vi.cpp | 52 ++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index d380c60fb..5b0e371fe 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -215,10 +215,9 @@ public: explicit IGBPConnectRequestParcel(std::vector buffer) : Parcel(std::move(buffer)) { Deserialize(); } - ~IGBPConnectRequestParcel() override = default; void DeserializeData() override { - std::u16string token = ReadInterfaceToken(); + [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); data = Read(); } @@ -279,10 +278,9 @@ public: : Parcel(std::move(buffer)) { Deserialize(); } - ~IGBPSetPreallocatedBufferRequestParcel() override = default; void DeserializeData() override { - std::u16string token = ReadInterfaceToken(); + [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); data = Read(); buffer = Read(); } @@ -306,15 +304,40 @@ protected: } }; +class IGBPCancelBufferRequestParcel : public Parcel { +public: + explicit IGBPCancelBufferRequestParcel(std::vector buffer) : Parcel(std::move(buffer)) { + Deserialize(); + } + + void DeserializeData() override { + [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); + data = Read(); + } + + struct Data { + u32_le slot; + Service::Nvidia::MultiFence multi_fence; + }; + + Data data; +}; + +class IGBPCancelBufferResponseParcel : public Parcel { +protected: + void SerializeData() override { + Write(0); // Success + } +}; + class IGBPDequeueBufferRequestParcel : public Parcel { public: explicit IGBPDequeueBufferRequestParcel(std::vector buffer) : Parcel(std::move(buffer)) { Deserialize(); } - ~IGBPDequeueBufferRequestParcel() override = default; void DeserializeData() override { - std::u16string token = ReadInterfaceToken(); + [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); data = Read(); } @@ -333,7 +356,6 @@ class IGBPDequeueBufferResponseParcel : public Parcel { public: explicit IGBPDequeueBufferResponseParcel(u32 slot, Service::Nvidia::MultiFence& multi_fence) : slot(slot), multi_fence(multi_fence) {} - ~IGBPDequeueBufferResponseParcel() override = default; protected: void SerializeData() override { @@ -352,10 +374,9 @@ public: explicit IGBPRequestBufferRequestParcel(std::vector buffer) : Parcel(std::move(buffer)) { Deserialize(); } - ~IGBPRequestBufferRequestParcel() override = default; void DeserializeData() override { - std::u16string token = ReadInterfaceToken(); + [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); slot = Read(); } @@ -384,10 +405,9 @@ public: explicit IGBPQueueBufferRequestParcel(std::vector buffer) : Parcel(std::move(buffer)) { Deserialize(); } - ~IGBPQueueBufferRequestParcel() override = default; void DeserializeData() override { - std::u16string token = ReadInterfaceToken(); + [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); data = Read(); } @@ -447,10 +467,9 @@ public: explicit IGBPQueryRequestParcel(std::vector buffer) : Parcel(std::move(buffer)) { Deserialize(); } - ~IGBPQueryRequestParcel() override = default; void DeserializeData() override { - std::u16string token = ReadInterfaceToken(); + [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); type = Read(); } @@ -596,7 +615,12 @@ private: break; } case TransactionId::CancelBuffer: { - LOG_CRITICAL(Service_VI, "(STUBBED) called, transaction=CancelBuffer"); + IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()}; + + buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence); + + IGBPCancelBufferResponseParcel response{}; + ctx.WriteBuffer(response.Serialize()); break; } case TransactionId::Disconnect: { -- cgit v1.2.3 From 8f2959f6804e0d1048ecaa6f4046622e069fe7db Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Mon, 28 Sep 2020 10:00:15 -0400 Subject: settings: Preparation for per-game input settings --- src/core/hle/service/vi/vi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 5b0e371fe..55e00dd93 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -771,7 +771,7 @@ private: IPC::ResponseBuilder rb{ctx, 6}; rb.Push(RESULT_SUCCESS); - if (Settings::values.use_docked_mode) { + if (Settings::values.use_docked_mode.GetValue()) { rb.Push(static_cast(Service::VI::DisplayResolution::DockedWidth) * static_cast(Settings::values.resolution_factor.GetValue())); rb.Push(static_cast(Service::VI::DisplayResolution::DockedHeight) * -- cgit v1.2.3 From 7791cc8c2e585dcc377e22a26f548db914250a5d Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 24 Nov 2020 14:31:58 -0800 Subject: hle: services: Fix a crash with improper NVFlinger lifetime management. (#4977) * hle: services: Fix a crash with improper NVFlinger lifetime management. - This crash would happen when attempting to shutdown yuzu early on in boot. --- src/core/hle/service/vi/vi.cpp | 57 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 30 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 55e00dd93..86bd604f4 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -492,8 +492,8 @@ private: class IHOSBinderDriver final : public ServiceFramework { public: - explicit IHOSBinderDriver(std::shared_ptr nv_flinger) - : ServiceFramework("IHOSBinderDriver"), nv_flinger(std::move(nv_flinger)) { + explicit IHOSBinderDriver(NVFlinger::NVFlinger& nv_flinger) + : ServiceFramework("IHOSBinderDriver"), nv_flinger(nv_flinger) { static const FunctionInfo functions[] = { {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, @@ -530,8 +530,8 @@ private: LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, static_cast(transaction), flags); - const auto guard = nv_flinger->Lock(); - auto& buffer_queue = nv_flinger->FindBufferQueue(id); + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); switch (transaction) { case TransactionId::Connect: { @@ -570,8 +570,8 @@ private: [=, this](std::shared_ptr thread, Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) { // Repeat TransactParcel DequeueBuffer when a buffer is available - const auto guard = nv_flinger->Lock(); - auto& buffer_queue = nv_flinger->FindBufferQueue(id); + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); auto result = buffer_queue.DequeueBuffer(width, height); ASSERT_MSG(result != std::nullopt, "Could not dequeue buffer."); @@ -676,7 +676,7 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); - const auto& buffer_queue = nv_flinger->FindBufferQueue(id); + const auto& buffer_queue = nv_flinger.FindBufferQueue(id); // TODO(Subv): Find out what this actually is. IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -684,8 +684,8 @@ private: rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent()); } - std::shared_ptr nv_flinger; -}; // namespace VI + NVFlinger::NVFlinger& nv_flinger; +}; class ISystemDisplayService final : public ServiceFramework { public: @@ -790,8 +790,8 @@ private: class IManagerDisplayService final : public ServiceFramework { public: - explicit IManagerDisplayService(std::shared_ptr nv_flinger) - : ServiceFramework("IManagerDisplayService"), nv_flinger(std::move(nv_flinger)) { + explicit IManagerDisplayService(NVFlinger::NVFlinger& nv_flinger) + : ServiceFramework("IManagerDisplayService"), nv_flinger(nv_flinger) { // clang-format off static const FunctionInfo functions[] = { {200, nullptr, "AllocateProcessHeapBlock"}, @@ -893,7 +893,7 @@ private: "(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}", unknown, display, aruid); - const auto layer_id = nv_flinger->CreateLayer(display); + const auto layer_id = nv_flinger.CreateLayer(display); if (!layer_id) { LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display); IPC::ResponseBuilder rb{ctx, 2}; @@ -930,12 +930,12 @@ private: rb.Push(RESULT_SUCCESS); } - std::shared_ptr nv_flinger; + NVFlinger::NVFlinger& nv_flinger; }; class IApplicationDisplayService final : public ServiceFramework { public: - explicit IApplicationDisplayService(std::shared_ptr nv_flinger); + explicit IApplicationDisplayService(NVFlinger::NVFlinger& nv_flinger); private: enum class ConvertedScaleMode : u64 { @@ -1010,7 +1010,7 @@ private: ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet"); - const auto display_id = nv_flinger->OpenDisplay(name); + const auto display_id = nv_flinger.OpenDisplay(name); if (!display_id) { LOG_ERROR(Service_VI, "Display not found! display_name={}", name); IPC::ResponseBuilder rb{ctx, 2}; @@ -1110,7 +1110,7 @@ private: LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid); - const auto display_id = nv_flinger->OpenDisplay(display_name); + const auto display_id = nv_flinger.OpenDisplay(display_name); if (!display_id) { LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -1118,7 +1118,7 @@ private: return; } - const auto buffer_queue_id = nv_flinger->FindBufferQueueId(*display_id, layer_id); + const auto buffer_queue_id = nv_flinger.FindBufferQueueId(*display_id, layer_id); if (!buffer_queue_id) { LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -1138,7 +1138,7 @@ private: LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id); - nv_flinger->CloseLayer(layer_id); + nv_flinger.CloseLayer(layer_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); @@ -1154,7 +1154,7 @@ private: // TODO(Subv): What's the difference between a Stray and a Managed layer? - const auto layer_id = nv_flinger->CreateLayer(display_id); + const auto layer_id = nv_flinger.CreateLayer(display_id); if (!layer_id) { LOG_ERROR(Service_VI, "Layer not found! layer_id={}", *layer_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -1162,7 +1162,7 @@ private: return; } - const auto buffer_queue_id = nv_flinger->FindBufferQueueId(display_id, *layer_id); + const auto buffer_queue_id = nv_flinger.FindBufferQueueId(display_id, *layer_id); if (!buffer_queue_id) { LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -1193,7 +1193,7 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called. display_id=0x{:016X}", display_id); - const auto vsync_event = nv_flinger->FindVsyncEvent(display_id); + const auto vsync_event = nv_flinger.FindVsyncEvent(display_id); if (!vsync_event) { LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id); IPC::ResponseBuilder rb{ctx, 2}; @@ -1258,12 +1258,11 @@ private: } } - std::shared_ptr nv_flinger; + NVFlinger::NVFlinger& nv_flinger; }; -IApplicationDisplayService::IApplicationDisplayService( - std::shared_ptr nv_flinger) - : ServiceFramework("IApplicationDisplayService"), nv_flinger(std::move(nv_flinger)) { +IApplicationDisplayService::IApplicationDisplayService(NVFlinger::NVFlinger& nv_flinger) + : ServiceFramework("IApplicationDisplayService"), nv_flinger(nv_flinger) { static const FunctionInfo functions[] = { {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"}, {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"}, @@ -1304,8 +1303,7 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) { return false; } -void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, - std::shared_ptr nv_flinger, +void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, NVFlinger::NVFlinger& nv_flinger, Permission permission) { IPC::RequestParser rp{ctx}; const auto policy = rp.PopEnum(); @@ -1319,11 +1317,10 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(std::move(nv_flinger)); + rb.PushIpcInterface(nv_flinger); } -void InstallInterfaces(SM::ServiceManager& service_manager, - std::shared_ptr nv_flinger) { +void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nv_flinger) { std::make_shared(nv_flinger)->InstallAsService(service_manager); std::make_shared(nv_flinger)->InstallAsService(service_manager); std::make_shared(nv_flinger)->InstallAsService(service_manager); -- cgit v1.2.3 From 1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 26 Nov 2020 15:19:08 -0500 Subject: service: Eliminate usages of the global system instance Completely removes all usages of the global system instance within the services code by passing in the using system instance to the services. --- src/core/hle/service/vi/vi.cpp | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 86bd604f4..af5b8b0b9 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -492,8 +492,8 @@ private: class IHOSBinderDriver final : public ServiceFramework { public: - explicit IHOSBinderDriver(NVFlinger::NVFlinger& nv_flinger) - : ServiceFramework("IHOSBinderDriver"), nv_flinger(nv_flinger) { + explicit IHOSBinderDriver(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_) + : ServiceFramework{system_, "IHOSBinderDriver"}, nv_flinger(nv_flinger_) { static const FunctionInfo functions[] = { {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, @@ -689,7 +689,8 @@ private: class ISystemDisplayService final : public ServiceFramework { public: - explicit ISystemDisplayService() : ServiceFramework("ISystemDisplayService") { + explicit ISystemDisplayService(Core::System& system_) + : ServiceFramework{system_, "ISystemDisplayService"} { static const FunctionInfo functions[] = { {1200, nullptr, "GetZOrderCountMin"}, {1202, nullptr, "GetZOrderCountMax"}, @@ -790,8 +791,8 @@ private: class IManagerDisplayService final : public ServiceFramework { public: - explicit IManagerDisplayService(NVFlinger::NVFlinger& nv_flinger) - : ServiceFramework("IManagerDisplayService"), nv_flinger(nv_flinger) { + explicit IManagerDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_) + : ServiceFramework{system_, "IManagerDisplayService"}, nv_flinger{nv_flinger_} { // clang-format off static const FunctionInfo functions[] = { {200, nullptr, "AllocateProcessHeapBlock"}, @@ -935,7 +936,7 @@ private: class IApplicationDisplayService final : public ServiceFramework { public: - explicit IApplicationDisplayService(NVFlinger::NVFlinger& nv_flinger); + explicit IApplicationDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_); private: enum class ConvertedScaleMode : u64 { @@ -959,7 +960,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(nv_flinger); + rb.PushIpcInterface(system, nv_flinger); } void GetSystemDisplayService(Kernel::HLERequestContext& ctx) { @@ -967,7 +968,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(); + rb.PushIpcInterface(system); } void GetManagerDisplayService(Kernel::HLERequestContext& ctx) { @@ -975,7 +976,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(nv_flinger); + rb.PushIpcInterface(system, nv_flinger); } void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx) { @@ -983,7 +984,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(nv_flinger); + rb.PushIpcInterface(system, nv_flinger); } void OpenDisplay(Kernel::HLERequestContext& ctx) { @@ -1261,8 +1262,9 @@ private: NVFlinger::NVFlinger& nv_flinger; }; -IApplicationDisplayService::IApplicationDisplayService(NVFlinger::NVFlinger& nv_flinger) - : ServiceFramework("IApplicationDisplayService"), nv_flinger(nv_flinger) { +IApplicationDisplayService::IApplicationDisplayService(Core::System& system_, + NVFlinger::NVFlinger& nv_flinger_) + : ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_} { static const FunctionInfo functions[] = { {100, &IApplicationDisplayService::GetRelayService, "GetRelayService"}, {101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"}, @@ -1303,8 +1305,8 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) { return false; } -void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, NVFlinger::NVFlinger& nv_flinger, - Permission permission) { +void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, + NVFlinger::NVFlinger& nv_flinger, Permission permission) { IPC::RequestParser rp{ctx}; const auto policy = rp.PopEnum(); @@ -1317,13 +1319,14 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, NVFlinger::NV IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(nv_flinger); + rb.PushIpcInterface(system, nv_flinger); } -void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nv_flinger) { - std::make_shared(nv_flinger)->InstallAsService(service_manager); - std::make_shared(nv_flinger)->InstallAsService(service_manager); - std::make_shared(nv_flinger)->InstallAsService(service_manager); +void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system, + NVFlinger::NVFlinger& nv_flinger) { + std::make_shared(system, nv_flinger)->InstallAsService(service_manager); + std::make_shared(system, nv_flinger)->InstallAsService(service_manager); + std::make_shared(system, nv_flinger)->InstallAsService(service_manager); } } // namespace Service::VI -- cgit v1.2.3 From 3373149fdc4dd4dc041fcd5501db5b4ccf0af7bb Mon Sep 17 00:00:00 2001 From: comex Date: Mon, 31 Aug 2020 10:34:46 -0400 Subject: hle: Type check ResponseBuilder::Push arguments, and fix use in vi.cpp - Add a type check so that calling Push with an invalid type produces a compile error rather than a linker error. - vi.cpp was calling Push with a variable of type `std::size_t`. There's no explicit overload for `size_t`, but there is one for `u64`, which on most platforms is the same type as `size_t`. On macOS, however, it isn't: both types are 64 bits, but `size_t` is `unsigned long` and `u64` is `unsigned long long`. Regardless, it makes more sense to explicitly use `u64` here instead of `size_t`. --- src/core/hle/service/vi/vi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index af5b8b0b9..422e9e02f 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -1230,8 +1230,8 @@ private: const auto height = rp.Pop(); LOG_DEBUG(Service_VI, "called width={}, height={}", width, height); - constexpr std::size_t base_size = 0x20000; - constexpr std::size_t alignment = 0x1000; + constexpr u64 base_size = 0x20000; + constexpr u64 alignment = 0x1000; const auto texture_size = width * height * 4; const auto out_size = (texture_size + base_size - 1) / base_size * base_size; -- cgit v1.2.3 From 6b7320add44bf3d933063d0b93296222fd522ef6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Dec 2020 22:00:34 -0500 Subject: core: Remove unnecessary enum casts in log calls Follows the video core PR. fmt doesn't require casts for enum classes anymore, so we can remove quite a few casts. --- src/core/hle/service/vi/vi.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 422e9e02f..5d8841ae8 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -528,7 +528,7 @@ private: const u32 flags = rp.Pop(); LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, - static_cast(transaction), flags); + transaction, flags); const auto guard = nv_flinger.Lock(); auto& buffer_queue = nv_flinger.FindBufferQueue(id); @@ -1066,8 +1066,8 @@ private: const auto scaling_mode = rp.PopEnum(); const u64 unknown = rp.Pop(); - LOG_DEBUG(Service_VI, "called. scaling_mode=0x{:08X}, unknown=0x{:016X}", - static_cast(scaling_mode), unknown); + LOG_DEBUG(Service_VI, "called. scaling_mode=0x{:08X}, unknown=0x{:016X}", scaling_mode, + unknown); IPC::ResponseBuilder rb{ctx, 2}; @@ -1210,7 +1210,7 @@ private: void ConvertScalingMode(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto mode = rp.PopEnum(); - LOG_DEBUG(Service_VI, "called mode={}", static_cast(mode)); + LOG_DEBUG(Service_VI, "called mode={}", mode); const auto converted_mode = ConvertScalingModeImpl(mode); @@ -1311,7 +1311,7 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& const auto policy = rp.PopEnum(); if (!IsValidServiceAccess(permission, policy)) { - LOG_ERROR(Service_VI, "Permission denied for policy {}", static_cast(policy)); + LOG_ERROR(Service_VI, "Permission denied for policy {}", policy); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_PERMISSION_DENIED); return; -- cgit v1.2.3 From 8cb683f3b9a419c2472ead6750621c671a5becff Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Thu, 17 Dec 2020 14:22:46 -0500 Subject: Overwrite slots instead of queuing them, add disconnect signal Fix for Katana Zero and Yoshi's Crafted World --- src/core/hle/service/vi/vi.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 5d8841ae8..45cfffe06 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -282,18 +282,24 @@ public: void DeserializeData() override { [[maybe_unused]] const std::u16string token = ReadInterfaceToken(); data = Read(); - buffer = Read(); + if (data.contains_object != 0) { + buffer_container = Read(); + } } struct Data { u32_le slot; - INSERT_PADDING_WORDS(1); + u32_le contains_object; + }; + + struct BufferContainer { u32_le graphic_buffer_length; INSERT_PADDING_WORDS(1); + NVFlinger::IGBPBuffer buffer{}; }; - Data data; - NVFlinger::IGBPBuffer buffer; + Data data{}; + BufferContainer buffer_container{}; }; class IGBPSetPreallocatedBufferResponseParcel : public Parcel { @@ -547,7 +553,7 @@ private: case TransactionId::SetPreallocatedBuffer: { IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; - buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer); + buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer); IGBPSetPreallocatedBufferResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); -- cgit v1.2.3 From b377da042b39ac9bde1ca9be69009117372f33d3 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 9 Dec 2020 22:52:09 -0800 Subject: hle: service: vi: Remove usage of SleepClientThread. --- src/core/hle/service/vi/vi.cpp | 77 +++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 34 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 45cfffe06..93a113b93 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -536,9 +536,6 @@ private: LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, transaction, flags); - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); - switch (transaction) { case TransactionId::Connect: { IGBPConnectRequestParcel request{ctx.ReadBuffer()}; @@ -553,7 +550,11 @@ private: case TransactionId::SetPreallocatedBuffer: { IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; - buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer); + { + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); + buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer); + } IGBPSetPreallocatedBufferResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); @@ -563,48 +564,46 @@ private: IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; const u32 width{request.data.width}; const u32 height{request.data.height}; - auto result = buffer_queue.DequeueBuffer(width, height); - - if (result) { - // Buffer is available - IGBPDequeueBufferResponseParcel response{result->first, *result->second}; - ctx.WriteBuffer(response.Serialize()); - } else { - // Wait the current thread until a buffer becomes available - ctx.SleepClientThread( - "IHOSBinderDriver::DequeueBuffer", UINT64_MAX, - [=, this](std::shared_ptr thread, - Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) { - // Repeat TransactParcel DequeueBuffer when a buffer is available - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); - auto result = buffer_queue.DequeueBuffer(width, height); - ASSERT_MSG(result != std::nullopt, "Could not dequeue buffer."); - - IGBPDequeueBufferResponseParcel response{result->first, *result->second}; - ctx.WriteBuffer(response.Serialize()); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(RESULT_SUCCESS); - }, - buffer_queue.GetWritableBufferWaitEvent()); + + std::optional> result; + + while (!result) { + { + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); + result = buffer_queue.DequeueBuffer(width, height); + } + + if (result) { + // Buffer is available + IGBPDequeueBufferResponseParcel response{result->first, *result->second}; + ctx.WriteBuffer(response.Serialize()); + } } + break; } case TransactionId::RequestBuffer: { IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); auto& buffer = buffer_queue.RequestBuffer(request.slot); - IGBPRequestBufferResponseParcel response{buffer}; ctx.WriteBuffer(response.Serialize()); + break; } case TransactionId::QueueBuffer: { IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; - buffer_queue.QueueBuffer(request.data.slot, request.data.transform, - request.data.GetCropRect(), request.data.swap_interval, - request.data.multi_fence); + { + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); + buffer_queue.QueueBuffer(request.data.slot, request.data.transform, + request.data.GetCropRect(), request.data.swap_interval, + request.data.multi_fence); + } IGBPQueueBufferResponseParcel response{1280, 720}; ctx.WriteBuffer(response.Serialize()); @@ -613,6 +612,8 @@ private: case TransactionId::Query: { IGBPQueryRequestParcel request{ctx.ReadBuffer()}; + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); const u32 value = buffer_queue.Query(static_cast(request.type)); @@ -623,7 +624,11 @@ private: case TransactionId::CancelBuffer: { IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()}; - buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence); + { + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); + buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence); + } IGBPCancelBufferResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); @@ -633,7 +638,11 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called, transaction=Disconnect"); const auto buffer = ctx.ReadBuffer(); - buffer_queue.Disconnect(); + { + const auto guard = nv_flinger.Lock(); + auto& buffer_queue = nv_flinger.FindBufferQueue(id); + buffer_queue.Disconnect(); + } IGBPEmptyResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); -- cgit v1.2.3 From 19a8f03ad59abacb3fae60f7ba6d5d358e779c29 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 10 Dec 2020 15:32:52 -0800 Subject: hle: service: nvflinger: Refactor locking and interfaces. --- src/core/hle/service/vi/vi.cpp | 46 +++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 93a113b93..ce0272e59 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -551,9 +551,9 @@ private: IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; { - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); - buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer); + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + buffer_queue.SetPreallocatedBuffer(request.data.slot, + request.buffer_container.buffer); } IGBPSetPreallocatedBufferResponseParcel response{}; @@ -568,11 +568,8 @@ private: std::optional> result; while (!result) { - { - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); - result = buffer_queue.DequeueBuffer(width, height); - } + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + result = buffer_queue.DequeueBuffer(width, height); if (result) { // Buffer is available @@ -586,8 +583,7 @@ private: case TransactionId::RequestBuffer: { IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); auto& buffer = buffer_queue.RequestBuffer(request.slot); IGBPRequestBufferResponseParcel response{buffer}; ctx.WriteBuffer(response.Serialize()); @@ -597,13 +593,10 @@ private: case TransactionId::QueueBuffer: { IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; - { - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); - buffer_queue.QueueBuffer(request.data.slot, request.data.transform, - request.data.GetCropRect(), request.data.swap_interval, - request.data.multi_fence); - } + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + buffer_queue.QueueBuffer(request.data.slot, request.data.transform, + request.data.GetCropRect(), request.data.swap_interval, + request.data.multi_fence); IGBPQueueBufferResponseParcel response{1280, 720}; ctx.WriteBuffer(response.Serialize()); @@ -612,8 +605,7 @@ private: case TransactionId::Query: { IGBPQueryRequestParcel request{ctx.ReadBuffer()}; - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); const u32 value = buffer_queue.Query(static_cast(request.type)); @@ -624,11 +616,8 @@ private: case TransactionId::CancelBuffer: { IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()}; - { - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); - buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence); - } + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence); IGBPCancelBufferResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); @@ -638,11 +627,8 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called, transaction=Disconnect"); const auto buffer = ctx.ReadBuffer(); - { - const auto guard = nv_flinger.Lock(); - auto& buffer_queue = nv_flinger.FindBufferQueue(id); - buffer_queue.Disconnect(); - } + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + buffer_queue.Disconnect(); IGBPEmptyResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); @@ -691,7 +677,7 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); - const auto& buffer_queue = nv_flinger.FindBufferQueue(id); + const auto& buffer_queue = *nv_flinger.FindBufferQueue(id); // TODO(Subv): Find out what this actually is. IPC::ResponseBuilder rb{ctx, 2, 1}; -- cgit v1.2.3 From 6433b1dfd67f4c4f0c4b2e3742dc437a0d1e906e Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 16 Dec 2020 21:09:06 -0800 Subject: service: nvflinger: Improve synchronization for BufferQueue. - Use proper mechanisms for blocking on DequeueBuffer. - Ensure service thread terminates on emulation Shutdown. --- src/core/hle/service/vi/vi.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index ce0272e59..1051000f8 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -544,6 +544,12 @@ private: Settings::values.resolution_factor.GetValue()), static_cast(static_cast(DisplayResolution::UndockedHeight) * Settings::values.resolution_factor.GetValue())}; + + { + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + buffer_queue.Connect(); + } + ctx.WriteBuffer(response.Serialize()); break; } @@ -565,18 +571,15 @@ private: const u32 width{request.data.width}; const u32 height{request.data.height}; - std::optional> result; - - while (!result) { - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); - result = buffer_queue.DequeueBuffer(width, height); - - if (result) { + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + do { + if (auto result = buffer_queue.DequeueBuffer(width, height); result) { // Buffer is available IGBPDequeueBufferResponseParcel response{result->first, *result->second}; ctx.WriteBuffer(response.Serialize()); + break; } - } + } while (buffer_queue.IsConnected()); break; } -- cgit v1.2.3 From 994a9fec4e8fb70df10ec7699c641db68d960795 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 20 Dec 2020 22:24:05 -0800 Subject: hle: service: vi: Refactor to grab buffer only once. --- src/core/hle/service/vi/vi.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/core/hle/service/vi/vi.cpp') diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 1051000f8..968cd16b6 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -536,6 +536,8 @@ private: LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, transaction, flags); + auto& buffer_queue = *nv_flinger.FindBufferQueue(id); + switch (transaction) { case TransactionId::Connect: { IGBPConnectRequestParcel request{ctx.ReadBuffer()}; @@ -545,10 +547,7 @@ private: static_cast(static_cast(DisplayResolution::UndockedHeight) * Settings::values.resolution_factor.GetValue())}; - { - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); - buffer_queue.Connect(); - } + buffer_queue.Connect(); ctx.WriteBuffer(response.Serialize()); break; @@ -556,11 +555,7 @@ private: case TransactionId::SetPreallocatedBuffer: { IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; - { - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); - buffer_queue.SetPreallocatedBuffer(request.data.slot, - request.buffer_container.buffer); - } + buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer); IGBPSetPreallocatedBufferResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); @@ -571,7 +566,6 @@ private: const u32 width{request.data.width}; const u32 height{request.data.height}; - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); do { if (auto result = buffer_queue.DequeueBuffer(width, height); result) { // Buffer is available @@ -586,7 +580,6 @@ private: case TransactionId::RequestBuffer: { IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); auto& buffer = buffer_queue.RequestBuffer(request.slot); IGBPRequestBufferResponseParcel response{buffer}; ctx.WriteBuffer(response.Serialize()); @@ -596,7 +589,6 @@ private: case TransactionId::QueueBuffer: { IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); buffer_queue.QueueBuffer(request.data.slot, request.data.transform, request.data.GetCropRect(), request.data.swap_interval, request.data.multi_fence); @@ -608,7 +600,6 @@ private: case TransactionId::Query: { IGBPQueryRequestParcel request{ctx.ReadBuffer()}; - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); const u32 value = buffer_queue.Query(static_cast(request.type)); @@ -619,7 +610,6 @@ private: case TransactionId::CancelBuffer: { IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()}; - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence); IGBPCancelBufferResponseParcel response{}; @@ -630,7 +620,6 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called, transaction=Disconnect"); const auto buffer = ctx.ReadBuffer(); - auto& buffer_queue = *nv_flinger.FindBufferQueue(id); buffer_queue.Disconnect(); IGBPEmptyResponseParcel response{}; -- cgit v1.2.3