mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-29 18:35:44 +00:00
hle: service: vi: Remove usage of SleepClientThread.
This commit is contained in:
parent
28281ae250
commit
b377da042b
|
@ -536,9 +536,6 @@ private:
|
||||||
LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id,
|
LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id,
|
||||||
transaction, flags);
|
transaction, flags);
|
||||||
|
|
||||||
const auto guard = nv_flinger.Lock();
|
|
||||||
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
|
||||||
|
|
||||||
switch (transaction) {
|
switch (transaction) {
|
||||||
case TransactionId::Connect: {
|
case TransactionId::Connect: {
|
||||||
IGBPConnectRequestParcel request{ctx.ReadBuffer()};
|
IGBPConnectRequestParcel request{ctx.ReadBuffer()};
|
||||||
|
@ -553,7 +550,11 @@ private:
|
||||||
case TransactionId::SetPreallocatedBuffer: {
|
case TransactionId::SetPreallocatedBuffer: {
|
||||||
IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()};
|
IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()};
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto guard = nv_flinger.Lock();
|
||||||
|
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
||||||
buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer);
|
buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer_container.buffer);
|
||||||
|
}
|
||||||
|
|
||||||
IGBPSetPreallocatedBufferResponseParcel response{};
|
IGBPSetPreallocatedBufferResponseParcel response{};
|
||||||
ctx.WriteBuffer(response.Serialize());
|
ctx.WriteBuffer(response.Serialize());
|
||||||
|
@ -563,48 +564,46 @@ private:
|
||||||
IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()};
|
IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()};
|
||||||
const u32 width{request.data.width};
|
const u32 width{request.data.width};
|
||||||
const u32 height{request.data.height};
|
const u32 height{request.data.height};
|
||||||
auto result = buffer_queue.DequeueBuffer(width, height);
|
|
||||||
|
std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> result;
|
||||||
|
|
||||||
|
while (!result) {
|
||||||
|
{
|
||||||
|
const auto guard = nv_flinger.Lock();
|
||||||
|
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
||||||
|
result = buffer_queue.DequeueBuffer(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
// Buffer is available
|
// Buffer is available
|
||||||
IGBPDequeueBufferResponseParcel response{result->first, *result->second};
|
IGBPDequeueBufferResponseParcel response{result->first, *result->second};
|
||||||
ctx.WriteBuffer(response.Serialize());
|
ctx.WriteBuffer(response.Serialize());
|
||||||
} else {
|
|
||||||
// Wait the current thread until a buffer becomes available
|
|
||||||
ctx.SleepClientThread(
|
|
||||||
"IHOSBinderDriver::DequeueBuffer", UINT64_MAX,
|
|
||||||
[=, this](std::shared_ptr<Kernel::Thread> thread,
|
|
||||||
Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) {
|
|
||||||
// Repeat TransactParcel DequeueBuffer when a buffer is available
|
|
||||||
const auto guard = nv_flinger.Lock();
|
|
||||||
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
|
||||||
auto result = buffer_queue.DequeueBuffer(width, height);
|
|
||||||
ASSERT_MSG(result != std::nullopt, "Could not dequeue buffer.");
|
|
||||||
|
|
||||||
IGBPDequeueBufferResponseParcel response{result->first, *result->second};
|
|
||||||
ctx.WriteBuffer(response.Serialize());
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(RESULT_SUCCESS);
|
|
||||||
},
|
|
||||||
buffer_queue.GetWritableBufferWaitEvent());
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TransactionId::RequestBuffer: {
|
case TransactionId::RequestBuffer: {
|
||||||
IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()};
|
IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()};
|
||||||
|
|
||||||
|
const auto guard = nv_flinger.Lock();
|
||||||
|
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
||||||
auto& buffer = buffer_queue.RequestBuffer(request.slot);
|
auto& buffer = buffer_queue.RequestBuffer(request.slot);
|
||||||
|
|
||||||
IGBPRequestBufferResponseParcel response{buffer};
|
IGBPRequestBufferResponseParcel response{buffer};
|
||||||
ctx.WriteBuffer(response.Serialize());
|
ctx.WriteBuffer(response.Serialize());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TransactionId::QueueBuffer: {
|
case TransactionId::QueueBuffer: {
|
||||||
IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()};
|
IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()};
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto guard = nv_flinger.Lock();
|
||||||
|
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
||||||
buffer_queue.QueueBuffer(request.data.slot, request.data.transform,
|
buffer_queue.QueueBuffer(request.data.slot, request.data.transform,
|
||||||
request.data.GetCropRect(), request.data.swap_interval,
|
request.data.GetCropRect(), request.data.swap_interval,
|
||||||
request.data.multi_fence);
|
request.data.multi_fence);
|
||||||
|
}
|
||||||
|
|
||||||
IGBPQueueBufferResponseParcel response{1280, 720};
|
IGBPQueueBufferResponseParcel response{1280, 720};
|
||||||
ctx.WriteBuffer(response.Serialize());
|
ctx.WriteBuffer(response.Serialize());
|
||||||
|
@ -613,6 +612,8 @@ private:
|
||||||
case TransactionId::Query: {
|
case TransactionId::Query: {
|
||||||
IGBPQueryRequestParcel request{ctx.ReadBuffer()};
|
IGBPQueryRequestParcel request{ctx.ReadBuffer()};
|
||||||
|
|
||||||
|
const auto guard = nv_flinger.Lock();
|
||||||
|
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
||||||
const u32 value =
|
const u32 value =
|
||||||
buffer_queue.Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type));
|
buffer_queue.Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type));
|
||||||
|
|
||||||
|
@ -623,7 +624,11 @@ private:
|
||||||
case TransactionId::CancelBuffer: {
|
case TransactionId::CancelBuffer: {
|
||||||
IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()};
|
IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()};
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto guard = nv_flinger.Lock();
|
||||||
|
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
||||||
buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence);
|
buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence);
|
||||||
|
}
|
||||||
|
|
||||||
IGBPCancelBufferResponseParcel response{};
|
IGBPCancelBufferResponseParcel response{};
|
||||||
ctx.WriteBuffer(response.Serialize());
|
ctx.WriteBuffer(response.Serialize());
|
||||||
|
@ -633,7 +638,11 @@ private:
|
||||||
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=Disconnect");
|
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=Disconnect");
|
||||||
const auto buffer = ctx.ReadBuffer();
|
const auto buffer = ctx.ReadBuffer();
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto guard = nv_flinger.Lock();
|
||||||
|
auto& buffer_queue = nv_flinger.FindBufferQueue(id);
|
||||||
buffer_queue.Disconnect();
|
buffer_queue.Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
IGBPEmptyResponseParcel response{};
|
IGBPEmptyResponseParcel response{};
|
||||||
ctx.WriteBuffer(response.Serialize());
|
ctx.WriteBuffer(response.Serialize());
|
||||||
|
|
Loading…
Reference in a new issue