diff options
| author | 2023-09-28 23:45:49 -0600 | |
|---|---|---|
| committer | 2023-10-01 11:38:30 -0600 | |
| commit | 35f25882e027fd3c466edd44db1fc1c5bec75bde (patch) | |
| tree | 8f7be0d40cc8ebb2bbbb8fec4113293bc72f5071 /src/core/hle/service/vi | |
| parent | service: ldn: Implement lp2p:m and stub IMonitorService (diff) | |
| download | yuzu-35f25882e027fd3c466edd44db1fc1c5bec75bde.tar.gz yuzu-35f25882e027fd3c466edd44db1fc1c5bec75bde.tar.xz yuzu-35f25882e027fd3c466edd44db1fc1c5bec75bde.zip | |
service: nvnflinger: Implement shared buffer
Co-authored-by: Liam <byteslice@airmail.cc>
Diffstat (limited to 'src/core/hle/service/vi')
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 129 |
1 files changed, 120 insertions, 9 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 2eb978379..b1bfb9898 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -20,9 +20,12 @@ | |||
| 20 | #include "core/hle/kernel/k_readable_event.h" | 20 | #include "core/hle/kernel/k_readable_event.h" |
| 21 | #include "core/hle/kernel/k_thread.h" | 21 | #include "core/hle/kernel/k_thread.h" |
| 22 | #include "core/hle/service/ipc_helpers.h" | 22 | #include "core/hle/service/ipc_helpers.h" |
| 23 | #include "core/hle/service/nvdrv/devices/nvmap.h" | ||
| 23 | #include "core/hle/service/nvdrv/nvdata.h" | 24 | #include "core/hle/service/nvdrv/nvdata.h" |
| 25 | #include "core/hle/service/nvdrv/nvdrv.h" | ||
| 24 | #include "core/hle/service/nvnflinger/binder.h" | 26 | #include "core/hle/service/nvnflinger/binder.h" |
| 25 | #include "core/hle/service/nvnflinger/buffer_queue_producer.h" | 27 | #include "core/hle/service/nvnflinger/buffer_queue_producer.h" |
| 28 | #include "core/hle/service/nvnflinger/fb_share_buffer_manager.h" | ||
| 26 | #include "core/hle/service/nvnflinger/hos_binder_driver_server.h" | 29 | #include "core/hle/service/nvnflinger/hos_binder_driver_server.h" |
| 27 | #include "core/hle/service/nvnflinger/nvnflinger.h" | 30 | #include "core/hle/service/nvnflinger/nvnflinger.h" |
| 28 | #include "core/hle/service/nvnflinger/parcel.h" | 31 | #include "core/hle/service/nvnflinger/parcel.h" |
| @@ -131,8 +134,9 @@ private: | |||
| 131 | 134 | ||
| 132 | class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { | 135 | class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { |
| 133 | public: | 136 | public: |
| 134 | explicit ISystemDisplayService(Core::System& system_) | 137 | explicit ISystemDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_) |
| 135 | : ServiceFramework{system_, "ISystemDisplayService"} { | 138 | : ServiceFramework{system_, "ISystemDisplayService"}, nvnflinger{nvnflinger_} { |
| 139 | // clang-format off | ||
| 136 | static const FunctionInfo functions[] = { | 140 | static const FunctionInfo functions[] = { |
| 137 | {1200, nullptr, "GetZOrderCountMin"}, | 141 | {1200, nullptr, "GetZOrderCountMin"}, |
| 138 | {1202, nullptr, "GetZOrderCountMax"}, | 142 | {1202, nullptr, "GetZOrderCountMax"}, |
| @@ -170,22 +174,126 @@ public: | |||
| 170 | {3217, nullptr, "SetDisplayCmuLuma"}, | 174 | {3217, nullptr, "SetDisplayCmuLuma"}, |
| 171 | {3218, nullptr, "SetDisplayCrcMode"}, | 175 | {3218, nullptr, "SetDisplayCrcMode"}, |
| 172 | {6013, nullptr, "GetLayerPresentationSubmissionTimestamps"}, | 176 | {6013, nullptr, "GetLayerPresentationSubmissionTimestamps"}, |
| 173 | {8225, nullptr, "GetSharedBufferMemoryHandleId"}, | 177 | {8225, &ISystemDisplayService::GetSharedBufferMemoryHandleId, "GetSharedBufferMemoryHandleId"}, |
| 174 | {8250, nullptr, "OpenSharedLayer"}, | 178 | {8250, &ISystemDisplayService::OpenSharedLayer, "OpenSharedLayer"}, |
| 175 | {8251, nullptr, "CloseSharedLayer"}, | 179 | {8251, nullptr, "CloseSharedLayer"}, |
| 176 | {8252, nullptr, "ConnectSharedLayer"}, | 180 | {8252, &ISystemDisplayService::ConnectSharedLayer, "ConnectSharedLayer"}, |
| 177 | {8253, nullptr, "DisconnectSharedLayer"}, | 181 | {8253, nullptr, "DisconnectSharedLayer"}, |
| 178 | {8254, nullptr, "AcquireSharedFrameBuffer"}, | 182 | {8254, &ISystemDisplayService::AcquireSharedFrameBuffer, "AcquireSharedFrameBuffer"}, |
| 179 | {8255, nullptr, "PresentSharedFrameBuffer"}, | 183 | {8255, &ISystemDisplayService::PresentSharedFrameBuffer, "PresentSharedFrameBuffer"}, |
| 180 | {8256, nullptr, "GetSharedFrameBufferAcquirableEvent"}, | 184 | {8256, &ISystemDisplayService::GetSharedFrameBufferAcquirableEvent, "GetSharedFrameBufferAcquirableEvent"}, |
| 181 | {8257, nullptr, "FillSharedFrameBufferColor"}, | 185 | {8257, nullptr, "FillSharedFrameBufferColor"}, |
| 182 | {8258, nullptr, "CancelSharedFrameBuffer"}, | 186 | {8258, nullptr, "CancelSharedFrameBuffer"}, |
| 183 | {9000, nullptr, "GetDp2hdmiController"}, | 187 | {9000, nullptr, "GetDp2hdmiController"}, |
| 184 | }; | 188 | }; |
| 189 | // clang-format on | ||
| 185 | RegisterHandlers(functions); | 190 | RegisterHandlers(functions); |
| 186 | } | 191 | } |
| 187 | 192 | ||
| 188 | private: | 193 | private: |
| 194 | void GetSharedBufferMemoryHandleId(HLERequestContext& ctx) { | ||
| 195 | IPC::RequestParser rp{ctx}; | ||
| 196 | const u64 buffer_id = rp.PopRaw<u64>(); | ||
| 197 | |||
| 198 | LOG_INFO(Service_VI, "called. buffer_id={:#x}", buffer_id); | ||
| 199 | |||
| 200 | struct OutputParameters { | ||
| 201 | s32 nvmap_handle; | ||
| 202 | u64 size; | ||
| 203 | }; | ||
| 204 | |||
| 205 | OutputParameters out{}; | ||
| 206 | Nvnflinger::SharedMemoryPoolLayout layout{}; | ||
| 207 | const auto result = nvnflinger.GetSystemBufferManager().GetSharedBufferMemoryHandleId( | ||
| 208 | &out.size, &out.nvmap_handle, &layout, buffer_id, 0); | ||
| 209 | |||
| 210 | ctx.WriteBuffer(&layout, sizeof(layout)); | ||
| 211 | |||
| 212 | IPC::ResponseBuilder rb{ctx, 6}; | ||
| 213 | rb.Push(result); | ||
| 214 | rb.PushRaw(out); | ||
| 215 | } | ||
| 216 | |||
| 217 | void OpenSharedLayer(HLERequestContext& ctx) { | ||
| 218 | IPC::RequestParser rp{ctx}; | ||
| 219 | const u64 layer_id = rp.PopRaw<u64>(); | ||
| 220 | |||
| 221 | LOG_INFO(Service_VI, "(STUBBED) called. layer_id={:#x}", layer_id); | ||
| 222 | |||
| 223 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 224 | rb.Push(ResultSuccess); | ||
| 225 | } | ||
| 226 | |||
| 227 | void ConnectSharedLayer(HLERequestContext& ctx) { | ||
| 228 | IPC::RequestParser rp{ctx}; | ||
| 229 | const u64 layer_id = rp.PopRaw<u64>(); | ||
| 230 | |||
| 231 | LOG_INFO(Service_VI, "(STUBBED) called. layer_id={:#x}", layer_id); | ||
| 232 | |||
| 233 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 234 | rb.Push(ResultSuccess); | ||
| 235 | } | ||
| 236 | |||
| 237 | void GetSharedFrameBufferAcquirableEvent(HLERequestContext& ctx) { | ||
| 238 | LOG_DEBUG(Service_VI, "called"); | ||
| 239 | |||
| 240 | IPC::RequestParser rp{ctx}; | ||
| 241 | const u64 layer_id = rp.PopRaw<u64>(); | ||
| 242 | |||
| 243 | Kernel::KReadableEvent* event{}; | ||
| 244 | const auto result = nvnflinger.GetSystemBufferManager().GetSharedFrameBufferAcquirableEvent( | ||
| 245 | &event, layer_id); | ||
| 246 | |||
| 247 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 248 | rb.Push(result); | ||
| 249 | rb.PushCopyObjects(event); | ||
| 250 | } | ||
| 251 | |||
| 252 | void AcquireSharedFrameBuffer(HLERequestContext& ctx) { | ||
| 253 | LOG_DEBUG(Service_VI, "called"); | ||
| 254 | |||
| 255 | IPC::RequestParser rp{ctx}; | ||
| 256 | const u64 layer_id = rp.PopRaw<u64>(); | ||
| 257 | |||
| 258 | struct OutputParameters { | ||
| 259 | android::Fence fence; | ||
| 260 | std::array<s32, 4> slots; | ||
| 261 | s64 target_slot; | ||
| 262 | }; | ||
| 263 | static_assert(sizeof(OutputParameters) == 0x40, "OutputParameters has wrong size"); | ||
| 264 | |||
| 265 | OutputParameters out{}; | ||
| 266 | const auto result = nvnflinger.GetSystemBufferManager().AcquireSharedFrameBuffer( | ||
| 267 | &out.fence, out.slots, &out.target_slot, layer_id); | ||
| 268 | |||
| 269 | IPC::ResponseBuilder rb{ctx, 18}; | ||
| 270 | rb.Push(result); | ||
| 271 | rb.PushRaw(out); | ||
| 272 | } | ||
| 273 | |||
| 274 | void PresentSharedFrameBuffer(HLERequestContext& ctx) { | ||
| 275 | LOG_DEBUG(Service_VI, "called"); | ||
| 276 | |||
| 277 | struct InputParameters { | ||
| 278 | android::Fence fence; | ||
| 279 | Common::Rectangle<s32> crop_region; | ||
| 280 | u32 window_transform; | ||
| 281 | s32 swap_interval; | ||
| 282 | u64 layer_id; | ||
| 283 | s64 surface_id; | ||
| 284 | }; | ||
| 285 | static_assert(sizeof(InputParameters) == 0x50, "InputParameters has wrong size"); | ||
| 286 | |||
| 287 | IPC::RequestParser rp{ctx}; | ||
| 288 | auto input = rp.PopRaw<InputParameters>(); | ||
| 289 | |||
| 290 | const auto result = nvnflinger.GetSystemBufferManager().PresentSharedFrameBuffer( | ||
| 291 | input.fence, input.crop_region, input.window_transform, input.swap_interval, | ||
| 292 | input.layer_id, input.surface_id); | ||
| 293 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 294 | rb.Push(result); | ||
| 295 | } | ||
| 296 | |||
| 189 | void SetLayerZ(HLERequestContext& ctx) { | 297 | void SetLayerZ(HLERequestContext& ctx) { |
| 190 | IPC::RequestParser rp{ctx}; | 298 | IPC::RequestParser rp{ctx}; |
| 191 | const u64 layer_id = rp.Pop<u64>(); | 299 | const u64 layer_id = rp.Pop<u64>(); |
| @@ -228,6 +336,9 @@ private: | |||
| 228 | rb.PushRaw<float>(60.0f); // This wouldn't seem to be correct for 30 fps games. | 336 | rb.PushRaw<float>(60.0f); // This wouldn't seem to be correct for 30 fps games. |
| 229 | rb.Push<u32>(0); | 337 | rb.Push<u32>(0); |
| 230 | } | 338 | } |
| 339 | |||
| 340 | private: | ||
| 341 | Nvnflinger::Nvnflinger& nvnflinger; | ||
| 231 | }; | 342 | }; |
| 232 | 343 | ||
| 233 | class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> { | 344 | class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> { |
| @@ -453,7 +564,7 @@ private: | |||
| 453 | 564 | ||
| 454 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 565 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 455 | rb.Push(ResultSuccess); | 566 | rb.Push(ResultSuccess); |
| 456 | rb.PushIpcInterface<ISystemDisplayService>(system); | 567 | rb.PushIpcInterface<ISystemDisplayService>(system, nv_flinger); |
| 457 | } | 568 | } |
| 458 | 569 | ||
| 459 | void GetManagerDisplayService(HLERequestContext& ctx) { | 570 | void GetManagerDisplayService(HLERequestContext& ctx) { |