From 8f84665775ca7732b20505f5472d640f3eaa8c1e Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 13 Feb 2018 21:54:12 -0500 Subject: [PATCH] vi: Use ReadBuffer/WriteBuffer functions for TransactParcel. --- src/core/hle/service/vi/vi.cpp | 117 +++++++++++++-------------------- 1 file changed, 46 insertions(+), 71 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,85 +453,60 @@ private: SetPreallocatedBuffer = 14 }; - void TransactParcel(u32 id, TransactionId transaction, const std::vector& input_data, - VAddr output_addr, u64 output_size) { - auto buffer_queue = nv_flinger->GetBufferQueue(id); - - if (transaction == TransactionId::Connect) { - IGBPConnectRequestParcel request{input_data}; - IGBPConnectResponseParcel response{1280, 720}; - std::vector response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); - } else if (transaction == TransactionId::SetPreallocatedBuffer) { - IGBPSetPreallocatedBufferRequestParcel request{input_data}; - - buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer); - - IGBPSetPreallocatedBufferResponseParcel response{}; - std::vector response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); - } else if (transaction == TransactionId::DequeueBuffer) { - IGBPDequeueBufferRequestParcel request{input_data}; - - u32 slot = buffer_queue->DequeueBuffer(request.data.pixel_format, request.data.width, - request.data.height); - - IGBPDequeueBufferResponseParcel response{slot}; - std::vector response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); - } else if (transaction == TransactionId::RequestBuffer) { - IGBPRequestBufferRequestParcel request{input_data}; - - auto& buffer = buffer_queue->RequestBuffer(request.slot); - - IGBPRequestBufferResponseParcel response{buffer}; - std::vector response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); - } else if (transaction == TransactionId::QueueBuffer) { - IGBPQueueBufferRequestParcel request{input_data}; - - buffer_queue->QueueBuffer(request.data.slot, request.data.transform); - - IGBPQueueBufferResponseParcel response{1280, 720}; - std::vector response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); - } else if (transaction == TransactionId::Query) { - IGBPQueryRequestParcel request{input_data}; - - u32 value = - buffer_queue->Query(static_cast(request.type)); - - IGBPQueryResponseParcel response{value}; - std::vector response_buffer = response.Serialize(); - Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size()); - } 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(); auto transaction = static_cast(rp.Pop()); u32 flags = rp.Pop(); + auto buffer_queue = nv_flinger->GetBufferQueue(id); + 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 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()); + if (transaction == TransactionId::Connect) { + IGBPConnectRequestParcel request{ctx.ReadBuffer()}; + IGBPConnectResponseParcel response{1280, 720}; + ctx.WriteBuffer(response.Serialize()); + } else if (transaction == TransactionId::SetPreallocatedBuffer) { + IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; + + buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer); + + IGBPSetPreallocatedBufferResponseParcel response{}; + ctx.WriteBuffer(response.Serialize()); + } else if (transaction == TransactionId::DequeueBuffer) { + IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; + + u32 slot = buffer_queue->DequeueBuffer(request.data.pixel_format, request.data.width, + request.data.height); + + IGBPDequeueBufferResponseParcel response{slot}; + ctx.WriteBuffer(response.Serialize()); + } else if (transaction == TransactionId::RequestBuffer) { + IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; + + auto& buffer = buffer_queue->RequestBuffer(request.slot); + + IGBPRequestBufferResponseParcel response{buffer}; + ctx.WriteBuffer(response.Serialize()); + } else if (transaction == TransactionId::QueueBuffer) { + IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; + + buffer_queue->QueueBuffer(request.data.slot, request.data.transform); + + IGBPQueueBufferResponseParcel response{1280, 720}; + ctx.WriteBuffer(response.Serialize()); + } else if (transaction == TransactionId::Query) { + IGBPQueryRequestParcel request{ctx.ReadBuffer()}; + + u32 value = + buffer_queue->Query(static_cast(request.type)); + + IGBPQueryResponseParcel response{value}; + ctx.WriteBuffer(response.Serialize()); + } else if (transaction == TransactionId::CancelBuffer) { + LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer"); } else { - auto& input_buffer = ctx.BufferDescriptorX()[0]; - auto& output_buffer = ctx.BufferDescriptorC()[0]; - std::vector 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()); + ASSERT_MSG(false, "Unimplemented"); } IPC::ResponseBuilder rb{ctx, 2};