From 4f01c13f5054e3af775fc956584b553da934d476 Mon Sep 17 00:00:00 2001 From: Ac_K Date: Sat, 2 Jan 2021 23:21:44 +0100 Subject: [PATCH] surfaceflinger: Fix fence callback issue (#1839) This PR fixes a regression introduced in #1741. The actual implementation do the assumption of fences always exist and then registering the callback. Homebrews may not use fences, so the code crashes when it try to register the callback. --- .../HOS/Services/SurfaceFlinger/SurfaceFlinger.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs index cec37a58b..297acdda9 100644 --- a/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs +++ b/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs @@ -345,14 +345,22 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger TextureCallbackInformation textureCallbackInformation = new TextureCallbackInformation { Layer = layer, - Item = item, + Item = item }; - item.Fence.RegisterCallback(_device.Gpu, () => + if (item.Fence.FenceCount == 0) { _device.Gpu.Window.SignalFrameReady(); _device.Gpu.GPFifo.Interrupt(); - }); + } + else + { + item.Fence.RegisterCallback(_device.Gpu, () => + { + _device.Gpu.Window.SignalFrameReady(); + _device.Gpu.GPFifo.Interrupt(); + }); + } _device.Gpu.Window.EnqueueFrameThreadSafe( frameBufferAddress,