summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Narr the Reg2024-01-09 11:15:56 -0600
committerGravatar GitHub2024-01-09 11:15:56 -0600
commit23c11e50f968558710c29154bd0d2c18cbe5ae92 (patch)
tree0ede4d6486061af3bcc2f6636c486420d27a9e4f
parentMerge pull request #12622 from liamwhite/format (diff)
parentvi: connect vsync event handle lifetime to application display service interface (diff)
downloadyuzu-23c11e50f968558710c29154bd0d2c18cbe5ae92.tar.gz
yuzu-23c11e50f968558710c29154bd0d2c18cbe5ae92.tar.xz
yuzu-23c11e50f968558710c29154bd0d2c18cbe5ae92.zip
Merge pull request #12609 from liamwhite/wrong-name-again
vi: minor cleanups
-rw-r--r--src/core/hle/service/nvnflinger/nvnflinger.cpp3
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp13
-rw-r--r--src/core/hle/service/vi/display/vi_display.h12
-rw-r--r--src/core/hle/service/vi/vi.cpp59
-rw-r--r--src/core/hle/service/vi/vi.h2
5 files changed, 38 insertions, 51 deletions
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp
index aa8aaa2d9..0469110e8 100644
--- a/src/core/hle/service/nvnflinger/nvnflinger.cpp
+++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp
@@ -223,7 +223,8 @@ Result Nvnflinger::FindVsyncEvent(Kernel::KReadableEvent** out_vsync_event, u64
223 return VI::ResultNotFound; 223 return VI::ResultNotFound;
224 } 224 }
225 225
226 return display->GetVSyncEvent(out_vsync_event); 226 *out_vsync_event = display->GetVSyncEvent();
227 return ResultSuccess;
227} 228}
228 229
229VI::Display* Nvnflinger::FindDisplay(u64 display_id) { 230VI::Display* Nvnflinger::FindDisplay(u64 display_id) {
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
index 71ce9be50..e2d9cd98a 100644
--- a/src/core/hle/service/vi/display/vi_display.cpp
+++ b/src/core/hle/service/vi/display/vi_display.cpp
@@ -71,18 +71,7 @@ size_t Display::GetNumLayers() const {
71 return std::ranges::count_if(layers, [](auto& l) { return l->IsOpen(); }); 71 return std::ranges::count_if(layers, [](auto& l) { return l->IsOpen(); });
72} 72}
73 73
74Result Display::GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event) { 74Kernel::KReadableEvent* Display::GetVSyncEvent() {
75 if (got_vsync_event) {
76 return ResultPermissionDenied;
77 }
78
79 got_vsync_event = true;
80
81 *out_vsync_event = GetVSyncEventUnchecked();
82 return ResultSuccess;
83}
84
85Kernel::KReadableEvent* Display::GetVSyncEventUnchecked() {
86 return &vsync_event->GetReadableEvent(); 75 return &vsync_event->GetReadableEvent();
87} 76}
88 77
diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h
index 1d9360b96..7e68ee79b 100644
--- a/src/core/hle/service/vi/display/vi_display.h
+++ b/src/core/hle/service/vi/display/vi_display.h
@@ -74,16 +74,8 @@ public:
74 74
75 std::size_t GetNumLayers() const; 75 std::size_t GetNumLayers() const;
76 76
77 /**
78 * Gets the internal vsync event.
79 *
80 * @returns The internal Vsync event if it has not yet been retrieved,
81 * VI::ResultPermissionDenied otherwise.
82 */
83 [[nodiscard]] Result GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event);
84
85 /// Gets the internal vsync event. 77 /// Gets the internal vsync event.
86 Kernel::KReadableEvent* GetVSyncEventUnchecked(); 78 Kernel::KReadableEvent* GetVSyncEvent();
87 79
88 /// Signals the internal vsync event. 80 /// Signals the internal vsync event.
89 void SignalVSyncEvent(); 81 void SignalVSyncEvent();
@@ -104,7 +96,6 @@ public:
104 /// Resets the display for a new connection. 96 /// Resets the display for a new connection.
105 void Reset() { 97 void Reset() {
106 layers.clear(); 98 layers.clear();
107 got_vsync_event = false;
108 } 99 }
109 100
110 /// Attempts to find a layer with the given ID. 101 /// Attempts to find a layer with the given ID.
@@ -133,7 +124,6 @@ private:
133 124
134 std::vector<std::unique_ptr<Layer>> layers; 125 std::vector<std::unique_ptr<Layer>> layers;
135 Kernel::KEvent* vsync_event{}; 126 Kernel::KEvent* vsync_event{};
136 bool got_vsync_event{false};
137}; 127};
138 128
139} // namespace Service::VI 129} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 9ab8788e3..39d5be90d 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -343,8 +343,8 @@ private:
343 343
344class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> { 344class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
345public: 345public:
346 explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_) 346 explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_)
347 : ServiceFramework{system_, "IManagerDisplayService"}, nv_flinger{nv_flinger_} { 347 : ServiceFramework{system_, "IManagerDisplayService"}, nvnflinger{nvnflinger_} {
348 // clang-format off 348 // clang-format off
349 static const FunctionInfo functions[] = { 349 static const FunctionInfo functions[] = {
350 {200, nullptr, "AllocateProcessHeapBlock"}, 350 {200, nullptr, "AllocateProcessHeapBlock"},
@@ -440,7 +440,7 @@ private:
440 IPC::RequestParser rp{ctx}; 440 IPC::RequestParser rp{ctx};
441 const u64 display = rp.Pop<u64>(); 441 const u64 display = rp.Pop<u64>();
442 442
443 const Result rc = nv_flinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown; 443 const Result rc = nvnflinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown;
444 444
445 IPC::ResponseBuilder rb{ctx, 2}; 445 IPC::ResponseBuilder rb{ctx, 2};
446 rb.Push(rc); 446 rb.Push(rc);
@@ -457,7 +457,7 @@ private:
457 "(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}", 457 "(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}",
458 unknown, display, aruid); 458 unknown, display, aruid);
459 459
460 const auto layer_id = nv_flinger.CreateLayer(display); 460 const auto layer_id = nvnflinger.CreateLayer(display);
461 if (!layer_id) { 461 if (!layer_id) {
462 LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display); 462 LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display);
463 IPC::ResponseBuilder rb{ctx, 2}; 463 IPC::ResponseBuilder rb{ctx, 2};
@@ -494,14 +494,14 @@ private:
494 rb.Push(ResultSuccess); 494 rb.Push(ResultSuccess);
495 } 495 }
496 496
497 Nvnflinger::Nvnflinger& nv_flinger; 497 Nvnflinger::Nvnflinger& nvnflinger;
498}; 498};
499 499
500class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { 500class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
501public: 501public:
502 IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, 502 IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_,
503 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) 503 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)
504 : ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_}, 504 : ServiceFramework{system_, "IApplicationDisplayService"}, nvnflinger{nvnflinger_},
505 hos_binder_driver_server{hos_binder_driver_server_} { 505 hos_binder_driver_server{hos_binder_driver_server_} {
506 506
507 static const FunctionInfo functions[] = { 507 static const FunctionInfo functions[] = {
@@ -564,7 +564,7 @@ private:
564 564
565 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 565 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
566 rb.Push(ResultSuccess); 566 rb.Push(ResultSuccess);
567 rb.PushIpcInterface<ISystemDisplayService>(system, nv_flinger); 567 rb.PushIpcInterface<ISystemDisplayService>(system, nvnflinger);
568 } 568 }
569 569
570 void GetManagerDisplayService(HLERequestContext& ctx) { 570 void GetManagerDisplayService(HLERequestContext& ctx) {
@@ -572,7 +572,7 @@ private:
572 572
573 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 573 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
574 rb.Push(ResultSuccess); 574 rb.Push(ResultSuccess);
575 rb.PushIpcInterface<IManagerDisplayService>(system, nv_flinger); 575 rb.PushIpcInterface<IManagerDisplayService>(system, nvnflinger);
576 } 576 }
577 577
578 void GetIndirectDisplayTransactionService(HLERequestContext& ctx) { 578 void GetIndirectDisplayTransactionService(HLERequestContext& ctx) {
@@ -607,7 +607,7 @@ private:
607 607
608 ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet"); 608 ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet");
609 609
610 const auto display_id = nv_flinger.OpenDisplay(name); 610 const auto display_id = nvnflinger.OpenDisplay(name);
611 if (!display_id) { 611 if (!display_id) {
612 LOG_ERROR(Service_VI, "Display not found! display_name={}", name); 612 LOG_ERROR(Service_VI, "Display not found! display_name={}", name);
613 IPC::ResponseBuilder rb{ctx, 2}; 613 IPC::ResponseBuilder rb{ctx, 2};
@@ -624,7 +624,7 @@ private:
624 IPC::RequestParser rp{ctx}; 624 IPC::RequestParser rp{ctx};
625 const u64 display_id = rp.Pop<u64>(); 625 const u64 display_id = rp.Pop<u64>();
626 626
627 const Result rc = nv_flinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown; 627 const Result rc = nvnflinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown;
628 628
629 IPC::ResponseBuilder rb{ctx, 2}; 629 IPC::ResponseBuilder rb{ctx, 2};
630 rb.Push(rc); 630 rb.Push(rc);
@@ -703,7 +703,7 @@ private:
703 703
704 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid); 704 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid);
705 705
706 const auto display_id = nv_flinger.OpenDisplay(display_name); 706 const auto display_id = nvnflinger.OpenDisplay(display_name);
707 if (!display_id) { 707 if (!display_id) {
708 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id); 708 LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
709 IPC::ResponseBuilder rb{ctx, 2}; 709 IPC::ResponseBuilder rb{ctx, 2};
@@ -711,7 +711,7 @@ private:
711 return; 711 return;
712 } 712 }
713 713
714 const auto buffer_queue_id = nv_flinger.FindBufferQueueId(*display_id, layer_id); 714 const auto buffer_queue_id = nvnflinger.FindBufferQueueId(*display_id, layer_id);
715 if (!buffer_queue_id) { 715 if (!buffer_queue_id) {
716 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id); 716 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
717 IPC::ResponseBuilder rb{ctx, 2}; 717 IPC::ResponseBuilder rb{ctx, 2};
@@ -719,7 +719,7 @@ private:
719 return; 719 return;
720 } 720 }
721 721
722 nv_flinger.OpenLayer(layer_id); 722 nvnflinger.OpenLayer(layer_id);
723 723
724 android::OutputParcel parcel; 724 android::OutputParcel parcel;
725 parcel.WriteInterface(NativeWindow{*buffer_queue_id}); 725 parcel.WriteInterface(NativeWindow{*buffer_queue_id});
@@ -737,7 +737,7 @@ private:
737 737
738 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id); 738 LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id);
739 739
740 nv_flinger.CloseLayer(layer_id); 740 nvnflinger.CloseLayer(layer_id);
741 741
742 IPC::ResponseBuilder rb{ctx, 2}; 742 IPC::ResponseBuilder rb{ctx, 2};
743 rb.Push(ResultSuccess); 743 rb.Push(ResultSuccess);
@@ -753,7 +753,7 @@ private:
753 753
754 // TODO(Subv): What's the difference between a Stray and a Managed layer? 754 // TODO(Subv): What's the difference between a Stray and a Managed layer?
755 755
756 const auto layer_id = nv_flinger.CreateLayer(display_id); 756 const auto layer_id = nvnflinger.CreateLayer(display_id);
757 if (!layer_id) { 757 if (!layer_id) {
758 LOG_ERROR(Service_VI, "Layer not found! display_id={}", display_id); 758 LOG_ERROR(Service_VI, "Layer not found! display_id={}", display_id);
759 IPC::ResponseBuilder rb{ctx, 2}; 759 IPC::ResponseBuilder rb{ctx, 2};
@@ -761,7 +761,7 @@ private:
761 return; 761 return;
762 } 762 }
763 763
764 const auto buffer_queue_id = nv_flinger.FindBufferQueueId(display_id, *layer_id); 764 const auto buffer_queue_id = nvnflinger.FindBufferQueueId(display_id, *layer_id);
765 if (!buffer_queue_id) { 765 if (!buffer_queue_id) {
766 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id); 766 LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
767 IPC::ResponseBuilder rb{ctx, 2}; 767 IPC::ResponseBuilder rb{ctx, 2};
@@ -785,7 +785,7 @@ private:
785 const u64 layer_id = rp.Pop<u64>(); 785 const u64 layer_id = rp.Pop<u64>();
786 786
787 LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}", layer_id); 787 LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}", layer_id);
788 nv_flinger.DestroyLayer(layer_id); 788 nvnflinger.DestroyLayer(layer_id);
789 789
790 IPC::ResponseBuilder rb{ctx, 2}; 790 IPC::ResponseBuilder rb{ctx, 2};
791 rb.Push(ResultSuccess); 791 rb.Push(ResultSuccess);
@@ -798,7 +798,7 @@ private:
798 LOG_DEBUG(Service_VI, "called. display_id={}", display_id); 798 LOG_DEBUG(Service_VI, "called. display_id={}", display_id);
799 799
800 Kernel::KReadableEvent* vsync_event{}; 800 Kernel::KReadableEvent* vsync_event{};
801 const auto result = nv_flinger.FindVsyncEvent(&vsync_event, display_id); 801 const auto result = nvnflinger.FindVsyncEvent(&vsync_event, display_id);
802 if (result != ResultSuccess) { 802 if (result != ResultSuccess) {
803 if (result == ResultNotFound) { 803 if (result == ResultNotFound) {
804 LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id); 804 LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
@@ -808,6 +808,12 @@ private:
808 rb.Push(result); 808 rb.Push(result);
809 return; 809 return;
810 } 810 }
811 if (vsync_event_fetched) {
812 IPC::ResponseBuilder rb{ctx, 2};
813 rb.Push(VI::ResultPermissionDenied);
814 return;
815 }
816 vsync_event_fetched = true;
811 817
812 IPC::ResponseBuilder rb{ctx, 2, 1}; 818 IPC::ResponseBuilder rb{ctx, 2, 1};
813 rb.Push(ResultSuccess); 819 rb.Push(ResultSuccess);
@@ -899,8 +905,9 @@ private:
899 } 905 }
900 } 906 }
901 907
902 Nvnflinger::Nvnflinger& nv_flinger; 908 Nvnflinger::Nvnflinger& nvnflinger;
903 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; 909 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server;
910 bool vsync_event_fetched{false};
904}; 911};
905 912
906static bool IsValidServiceAccess(Permission permission, Policy policy) { 913static bool IsValidServiceAccess(Permission permission, Policy policy) {
@@ -916,7 +923,7 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) {
916} 923}
917 924
918void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, 925void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
919 Nvnflinger::Nvnflinger& nv_flinger, 926 Nvnflinger::Nvnflinger& nvnflinger,
920 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, 927 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server,
921 Permission permission) { 928 Permission permission) {
922 IPC::RequestParser rp{ctx}; 929 IPC::RequestParser rp{ctx};
@@ -931,19 +938,19 @@ void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
931 938
932 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 939 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
933 rb.Push(ResultSuccess); 940 rb.Push(ResultSuccess);
934 rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger, hos_binder_driver_server); 941 rb.PushIpcInterface<IApplicationDisplayService>(system, nvnflinger, hos_binder_driver_server);
935} 942}
936 943
937void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger, 944void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
938 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) { 945 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) {
939 auto server_manager = std::make_unique<ServerManager>(system); 946 auto server_manager = std::make_unique<ServerManager>(system);
940 947
941 server_manager->RegisterNamedService( 948 server_manager->RegisterNamedService(
942 "vi:m", std::make_shared<VI_M>(system, nv_flinger, hos_binder_driver_server)); 949 "vi:m", std::make_shared<VI_M>(system, nvnflinger, hos_binder_driver_server));
943 server_manager->RegisterNamedService( 950 server_manager->RegisterNamedService(
944 "vi:s", std::make_shared<VI_S>(system, nv_flinger, hos_binder_driver_server)); 951 "vi:s", std::make_shared<VI_S>(system, nvnflinger, hos_binder_driver_server));
945 server_manager->RegisterNamedService( 952 server_manager->RegisterNamedService(
946 "vi:u", std::make_shared<VI_U>(system, nv_flinger, hos_binder_driver_server)); 953 "vi:u", std::make_shared<VI_U>(system, nvnflinger, hos_binder_driver_server));
947 ServerManager::RunServer(std::move(server_manager)); 954 ServerManager::RunServer(std::move(server_manager));
948} 955}
949 956
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h
index a35b62f97..ee4bcbcfa 100644
--- a/src/core/hle/service/vi/vi.h
+++ b/src/core/hle/service/vi/vi.h
@@ -48,7 +48,7 @@ void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,
48 Permission permission); 48 Permission permission);
49} // namespace detail 49} // namespace detail
50 50
51void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger, 51void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nvnflinger,
52 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); 52 Nvnflinger::HosBinderDriverServer& hos_binder_driver_server);
53 53
54} // namespace Service::VI 54} // namespace Service::VI