diff options
author | bunnei <bunneidev@gmail.com> | 2018-02-14 03:54:12 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-02-14 05:54:11 +0100 |
commit | 8f84665775ca7732b20505f5472d640f3eaa8c1e (patch) | |
tree | e0f3fc152ff065609b3a6fafc102c73aaca70723 /src | |
parent | hle_ipc: Add helper functions for reading and writing buffers. (diff) | |
download | yuzu-8f84665775ca7732b20505f5472d640f3eaa8c1e.tar yuzu-8f84665775ca7732b20505f5472d640f3eaa8c1e.tar.gz yuzu-8f84665775ca7732b20505f5472d640f3eaa8c1e.tar.bz2 yuzu-8f84665775ca7732b20505f5472d640f3eaa8c1e.tar.lz yuzu-8f84665775ca7732b20505f5472d640f3eaa8c1e.tar.xz yuzu-8f84665775ca7732b20505f5472d640f3eaa8c1e.tar.zst yuzu-8f84665775ca7732b20505f5472d640f3eaa8c1e.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/vi/vi.cpp | 63 |
1 files changed, 19 insertions, 44 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 55f196ab0..1f00a6cca 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -453,86 +453,61 @@ private: SetPreallocatedBuffer = 14 }; - void TransactParcel(u32 id, TransactionId transaction, const std::vector<u8>& input_data, - VAddr output_addr, u64 output_size) { + void TransactParcel(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + u32 id = rp.Pop<u32>(); + auto transaction = static_cast<TransactionId>(rp.Pop<u32>()); + u32 flags = rp.Pop<u32>(); auto buffer_queue = nv_flinger->GetBufferQueue(id); + LOG_DEBUG(Service_VI, "called, transaction=%x", transaction); + if (transaction == TransactionId::Connect) { - IGBPConnectRequestParcel request{input_data}; + IGBPConnectRequestParcel request{ctx.ReadBuffer()}; IGBPConnectResponseParcel response{1280, 720}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::SetPreallocatedBuffer) { - IGBPSetPreallocatedBufferRequestParcel request{input_data}; + IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer); IGBPSetPreallocatedBufferResponseParcel response{}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::DequeueBuffer) { - IGBPDequeueBufferRequestParcel request{input_data}; + IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; u32 slot = buffer_queue->DequeueBuffer(request.data.pixel_format, request.data.width, request.data.height); IGBPDequeueBufferResponseParcel response{slot}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::RequestBuffer) { - IGBPRequestBufferRequestParcel request{input_data}; + IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; auto& buffer = buffer_queue->RequestBuffer(request.slot); IGBPRequestBufferResponseParcel response{buffer}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::QueueBuffer) { - IGBPQueueBufferRequestParcel request{input_data}; + IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; buffer_queue->QueueBuffer(request.data.slot, request.data.transform); IGBPQueueBufferResponseParcel response{1280, 720}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::Query) { - IGBPQueryRequestParcel request{input_data}; + IGBPQueryRequestParcel request{ctx.ReadBuffer()}; u32 value = buffer_queue->Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type)); IGBPQueryResponseParcel response{value}; - std::vector<u8> response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); + ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::CancelBuffer) { LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer"); } else { ASSERT_MSG(false, "Unimplemented"); } - } - - void TransactParcel(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - u32 id = rp.Pop<u32>(); - auto transaction = static_cast<TransactionId>(rp.Pop<u32>()); - u32 flags = rp.Pop<u32>(); - LOG_DEBUG(Service_VI, "called, transaction=%x", transaction); - - if (ctx.BufferDescriptorA()[0].Size() != 0) { - auto& input_buffer = ctx.BufferDescriptorA()[0]; - auto& output_buffer = ctx.BufferDescriptorB()[0]; - std::vector<u8> input_data(input_buffer.Size()); - Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.Size()); - TransactParcel(id, transaction, input_data, output_buffer.Address(), - output_buffer.Size()); - } else { - auto& input_buffer = ctx.BufferDescriptorX()[0]; - auto& output_buffer = ctx.BufferDescriptorC()[0]; - std::vector<u8> input_data(input_buffer.size); - Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.size); - TransactParcel(id, transaction, input_data, output_buffer.Address(), - output_buffer.Size()); - } IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); |