From 8b2625b0be3020740a90f167e46f8f665102fef5 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 2 Oct 2023 19:13:29 -0300 Subject: [PATCH] Decrement nvmap reference count on surface flinger prealloc (#5753) --- .../HOS/Services/SurfaceFlinger/BufferQueueProducer.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs index 887d1861..55bfac84 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs @@ -669,6 +669,12 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger lock (Core.Lock) { + // If we are replacing a buffer that has already been queued, make sure we release the references. + if (Core.Slots[slot].BufferState == BufferState.Queued) + { + Core.Slots[slot].GraphicBuffer.Object.DecrementNvMapHandleRefCount(Core.Owner); + } + Core.Slots[slot].BufferState = BufferState.Free; Core.Slots[slot].Fence = AndroidFence.NoFence; Core.Slots[slot].RequestBufferCalled = false;