From 75ec30c962bcfa4251f29a29c659b959170018ce Mon Sep 17 00:00:00 2001 From: Thog Date: Sat, 25 Apr 2020 12:08:50 +0200 Subject: [PATCH] SurfaceFlinger: fix SetPreallocatedBuffer correctness (#1153) Nintendo sets the buffer count in SetPreallocatedBuffer too. This fix triple buffering on all games and finally fix SSBU flickering. --- .../HOS/Services/SurfaceFlinger/BufferQueueCore.cs | 2 +- .../Services/SurfaceFlinger/BufferQueueProducer.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs index 8a5f5831..88b4025d 100644 --- a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs +++ b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs @@ -43,7 +43,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger IsAbandoned = false; OverrideMaxBufferCount = 0; DequeueBufferCannotBlock = false; - UseAsyncBuffer = false; + UseAsyncBuffer = true; DefaultWidth = 1; DefaultHeight = 1; DefaultMaxBufferCount = 2; diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs index 29154356..333bffd1 100644 --- a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs +++ b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs @@ -604,6 +604,19 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Core.Slots[slot].GraphicBuffer.Object.Buffer.Usage &= (int)Core.ConsumerUsageBits; } + int bufferCount = 0; + + for (int i = 0; i < Core.Slots.Length; i++) + { + if (!Core.Slots[i].GraphicBuffer.IsNull) + { + bufferCount++; + } + } + + Core.OverrideMaxBufferCount = bufferCount; + Core.UseAsyncBuffer = false; + bool cleared = false; if (!graphicBuffer.IsNull)