From bcb7761eacaf9e40cc506648fec1eed58c23eff0 Mon Sep 17 00:00:00 2001 From: Thog Date: Tue, 2 Jun 2020 17:58:19 +0200 Subject: SurfaceFlinger: fix some bugs (#1262) * SurfaceFlinger: fix some bugs This fixes some bugs in the current implementation and make it closer to the real implementation. * Fix align of some variables --- .../HOS/Services/SurfaceFlinger/BufferQueueCore.cs | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs') diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs index 7386bafc..0b529a0e 100644 --- a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs +++ b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs @@ -33,6 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public BufferInfo[] BufferHistory; public uint BufferHistoryPosition; public bool EnableExternalEvent; + public int MaxBufferCountCached; public readonly object Lock = new object(); @@ -71,8 +72,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Owner = process; - BufferHistory = new BufferInfo[BufferHistoryArraySize]; - EnableExternalEvent = true; + BufferHistory = new BufferInfo[BufferHistoryArraySize]; + EnableExternalEvent = true; + MaxBufferCountCached = 0; } public int GetMinUndequeuedBufferCountLocked(bool async) @@ -95,6 +97,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger return GetMinUndequeuedBufferCountLocked(async); } + public void UpdateMaxBufferCountCachedLocked(int slot) + { + if (MaxBufferCountCached <= slot) + { + MaxBufferCountCached = slot + 1; + } + } + public int GetMaxBufferCountLocked(bool async) { int minMaxBufferCount = GetMinMaxBufferCountLocked(async); @@ -103,7 +113,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger if (OverrideMaxBufferCount != 0) { - maxBufferCount = OverrideMaxBufferCount; + return OverrideMaxBufferCount; } // Preserve all buffers already in control of the producer and the consumer. @@ -163,18 +173,20 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Monitor.Wait(Lock); } - public void SignalIsAbandonedEvent() + public void SignalIsAllocatingEvent() { Monitor.PulseAll(Lock); } - public void WaitIsAbandonedEvent() + public void WaitIsAllocatingEvent() { Monitor.Wait(Lock); } public void FreeBufferLocked(int slot) { + Slots[slot].GraphicBuffer.Reset(); + if (Slots[slot].BufferState == BufferState.Acquired) { Slots[slot].NeedsCleanupOnRelease = true; @@ -206,9 +218,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public void WaitWhileAllocatingLocked() { - while (IsAbandoned) + while (IsAllocating) { - WaitIsAbandonedEvent(); + WaitIsAllocatingEvent(); } } -- cgit v1.2.3