diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 25 | ||||
| -rw-r--r-- | src/core/hle/service/vi/vi.h | 16 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 1f218a4f5..4c9df099e 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -599,6 +599,8 @@ void IApplicationDisplayService::GetDisplayVsyncEvent(Kernel::HLERequestContext& | |||
| 599 | IPC::RequestParser rp{ctx}; | 599 | IPC::RequestParser rp{ctx}; |
| 600 | u64 display_id = rp.Pop<u64>(); | 600 | u64 display_id = rp.Pop<u64>(); |
| 601 | 601 | ||
| 602 | auto vsync_event = nv_flinger->GetVsyncEvent(display_id); | ||
| 603 | |||
| 602 | IPC::RequestBuilder rb = rp.MakeBuilder(2, 1, 0, 0); | 604 | IPC::RequestBuilder rb = rp.MakeBuilder(2, 1, 0, 0); |
| 603 | rb.Push(RESULT_SUCCESS); | 605 | rb.Push(RESULT_SUCCESS); |
| 604 | rb.PushCopyObjects(vsync_event); | 606 | rb.PushCopyObjects(vsync_event); |
| @@ -618,8 +620,6 @@ IApplicationDisplayService::IApplicationDisplayService(std::shared_ptr<NVFlinger | |||
| 618 | {5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"}, | 620 | {5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"}, |
| 619 | }; | 621 | }; |
| 620 | RegisterHandlers(functions); | 622 | RegisterHandlers(functions); |
| 621 | |||
| 622 | vsync_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "Display VSync Event"); | ||
| 623 | } | 623 | } |
| 624 | 624 | ||
| 625 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 625 | void InstallInterfaces(SM::ServiceManager& service_manager) { |
| @@ -628,10 +628,10 @@ void InstallInterfaces(SM::ServiceManager& service_manager) { | |||
| 628 | 628 | ||
| 629 | NVFlinger::NVFlinger() { | 629 | NVFlinger::NVFlinger() { |
| 630 | // Add the different displays to the list of displays. | 630 | // Add the different displays to the list of displays. |
| 631 | Display default_{"Default", 0}; | 631 | Display default_{0, "Default"}; |
| 632 | Display external{"External", 1}; | 632 | Display external{1, "External"}; |
| 633 | Display edid{"Edid", 2}; | 633 | Display edid{2, "Edid"}; |
| 634 | Display internal{"Internal", 3}; | 634 | Display internal{3, "Internal"}; |
| 635 | 635 | ||
| 636 | displays.emplace_back(default_); | 636 | displays.emplace_back(default_); |
| 637 | displays.emplace_back(external); | 637 | displays.emplace_back(external); |
| @@ -667,11 +667,16 @@ u64 NVFlinger::CreateLayer(u64 display_id) { | |||
| 667 | } | 667 | } |
| 668 | 668 | ||
| 669 | u32 NVFlinger::GetBufferQueueId(u64 display_id, u64 layer_id) { | 669 | u32 NVFlinger::GetBufferQueueId(u64 display_id, u64 layer_id) { |
| 670 | auto& layer = GetLayer(display_id, layer_id); | 670 | const auto& layer = GetLayer(display_id, layer_id); |
| 671 | return layer.buffer_queue->GetId(); | 671 | return layer.buffer_queue->GetId(); |
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | std::shared_ptr<BufferQueue> NVFlinger::GetBufferQueue(u32 id) { | 674 | Kernel::SharedPtr<Kernel::Event> NVFlinger::GetVsyncEvent(u64 display_id) { |
| 675 | const auto& display = GetDisplay(display_id); | ||
| 676 | return display.vsync_event; | ||
| 677 | } | ||
| 678 | |||
| 679 | std::shared_ptr<BufferQueue> NVFlinger::GetBufferQueue(u32 id) const { | ||
| 675 | auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), | 680 | auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), |
| 676 | [&](const auto& queue) { return queue->GetId() == id; }); | 681 | [&](const auto& queue) { return queue->GetId() == id; }); |
| 677 | 682 | ||
| @@ -745,5 +750,9 @@ void BufferQueue::QueueBuffer(u32 slot) { | |||
| 745 | 750 | ||
| 746 | Layer::Layer(u64 id, std::shared_ptr<BufferQueue> queue) : id(id), buffer_queue(std::move(queue)) {} | 751 | Layer::Layer(u64 id, std::shared_ptr<BufferQueue> queue) : id(id), buffer_queue(std::move(queue)) {} |
| 747 | 752 | ||
| 753 | Display::Display(u64 id, std::string name) : id(id), name(std::move(name)) { | ||
| 754 | vsync_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "Display VSync Event"); | ||
| 755 | } | ||
| 756 | |||
| 748 | } // namespace VI | 757 | } // namespace VI |
| 749 | } // namespace Service | 758 | } // namespace Service |
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index a83cd4902..029bd6831 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h | |||
| @@ -39,7 +39,9 @@ public: | |||
| 39 | const IGBPBuffer& RequestBuffer(u32 slot) const; | 39 | const IGBPBuffer& RequestBuffer(u32 slot) const; |
| 40 | void QueueBuffer(u32 slot); | 40 | void QueueBuffer(u32 slot); |
| 41 | 41 | ||
| 42 | u32 GetId() const { return id; } | 42 | u32 GetId() const { |
| 43 | return id; | ||
| 44 | } | ||
| 43 | 45 | ||
| 44 | private: | 46 | private: |
| 45 | u32 id; | 47 | u32 id; |
| @@ -65,10 +67,14 @@ struct Layer { | |||
| 65 | }; | 67 | }; |
| 66 | 68 | ||
| 67 | struct Display { | 69 | struct Display { |
| 68 | std::string name; | 70 | Display(u64 id, std::string name); |
| 71 | ~Display() = default; | ||
| 72 | |||
| 69 | u64 id; | 73 | u64 id; |
| 74 | std::string name; | ||
| 70 | 75 | ||
| 71 | std::vector<Layer> layers; | 76 | std::vector<Layer> layers; |
| 77 | Kernel::SharedPtr<Kernel::Event> vsync_event; | ||
| 72 | }; | 78 | }; |
| 73 | 79 | ||
| 74 | class NVFlinger { | 80 | class NVFlinger { |
| @@ -85,8 +91,11 @@ public: | |||
| 85 | /// Gets the buffer queue id of the specified layer in the specified display. | 91 | /// Gets the buffer queue id of the specified layer in the specified display. |
| 86 | u32 GetBufferQueueId(u64 display_id, u64 layer_id); | 92 | u32 GetBufferQueueId(u64 display_id, u64 layer_id); |
| 87 | 93 | ||
| 94 | /// Gets the vsync event for the specified display. | ||
| 95 | Kernel::SharedPtr<Kernel::Event> GetVsyncEvent(u64 display_id); | ||
| 96 | |||
| 88 | /// Obtains a buffer queue identified by the id. | 97 | /// Obtains a buffer queue identified by the id. |
| 89 | std::shared_ptr<BufferQueue> GetBufferQueue(u32 id); | 98 | std::shared_ptr<BufferQueue> GetBufferQueue(u32 id) const; |
| 90 | 99 | ||
| 91 | private: | 100 | private: |
| 92 | /// Returns the display identified by the specified id. | 101 | /// Returns the display identified by the specified id. |
| @@ -119,7 +128,6 @@ private: | |||
| 119 | void OpenLayer(Kernel::HLERequestContext& ctx); | 128 | void OpenLayer(Kernel::HLERequestContext& ctx); |
| 120 | void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx); | 129 | void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx); |
| 121 | 130 | ||
| 122 | Kernel::SharedPtr<Kernel::Event> vsync_event; | ||
| 123 | std::shared_ptr<NVFlinger> nv_flinger; | 131 | std::shared_ptr<NVFlinger> nv_flinger; |
| 124 | }; | 132 | }; |
| 125 | 133 | ||