Просмотр исходного кода

Try fixing NvFlinger rotation with scaling, return correct error code on WaitSignal timeout, always display window at the center of the screen

gdkchan 8 лет назад
Родитель
Сommit
344fc8a55d

+ 0 - 1
ChocolArm64/ATranslator.cs

@@ -7,7 +7,6 @@ using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Reflection.Emit;
-using System.Threading;
 
 namespace ChocolArm64
 {

+ 6 - 2
Ryujinx.Core/OsHle/CondVar.cs

@@ -24,7 +24,7 @@ namespace Ryujinx.Core.OsHle
             WaitingThreads = new List<HThread>();
         }
 
-        public void WaitForSignal(HThread Thread)
+        public bool WaitForSignal(HThread Thread)
         {
             int Count = Process.Memory.ReadInt32(CondVarAddress);
 
@@ -41,12 +41,14 @@ namespace Ryujinx.Core.OsHle
                 }
                 else
                 {
-                    Process.Scheduler.WaitForSignal(Thread, (int)(Timeout / 1000000));
+                    bool Result = Process.Scheduler.WaitForSignal(Thread, (int)(Timeout / 1000000));
 
                     lock (WaitingThreads)
                     {
                         WaitingThreads.Remove(Thread);
                     }
+
+                    return Result;
                 }
             }
 
@@ -60,6 +62,8 @@ namespace Ryujinx.Core.OsHle
             }
 
             ReleaseCondVarValue();
+
+            return true;
         }
 
         public void SetSignal(HThread Thread, int Count)

+ 8 - 4
Ryujinx.Core/OsHle/Handles/KProcessScheduler.cs

@@ -183,7 +183,7 @@ namespace Ryujinx.Core.OsHle.Handles
             TryResumingExecution(SchedThread);
         }
 
-        public void WaitForSignal(HThread Thread, int Timeout = -1)
+        public bool WaitForSignal(HThread Thread, int Timeout = -1)
         {
             SchedulerThread SchedThread;
 
@@ -206,22 +206,26 @@ namespace Ryujinx.Core.OsHle.Handles
                 {
                     Logging.Error($"{GetDbgThreadInfo(Thread)} was not found on the scheduler queue!");
 
-                    return;
+                    return false;
                 }
             }
 
+            bool Result;
+
             if (Timeout >= 0)
             {
                 Logging.Debug($"{GetDbgThreadInfo(Thread)} has wait timeout of {Timeout}ms.");
 
-                SchedThread.WaitEvent.WaitOne(Timeout);
+                Result = SchedThread.WaitEvent.WaitOne(Timeout);
             }
             else
             {
-                SchedThread.WaitEvent.WaitOne();
+                Result = SchedThread.WaitEvent.WaitOne();
             }
 
             TryResumingExecution(SchedThread);
+
+            return Result;
         }
 
         private void TryResumingExecution(SchedulerThread SchedThread)

+ 22 - 16
Ryujinx.Core/OsHle/Services/Vi/NvFlinger.cs

@@ -278,38 +278,44 @@ namespace Ryujinx.Core.OsHle.IpcServices.Android
             int RealWidth  = FbWidth;
             int RealHeight = FbHeight;
 
+            float XSign = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipX) ? -1 : 1;
+            float YSign = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipY) ? -1 : 1;
+
             float ScaleX = 1;
             float ScaleY = 1;
+
             float OffsX = 0;
             float OffsY = 0;
 
             if (Crop.Right  != 0 &&
                 Crop.Bottom != 0)
             {
+                //Who knows if this is right, I was never good with math...
                 RealWidth  = Crop.Right  - Crop.Left;
                 RealHeight = Crop.Bottom - Crop.Top;
 
-                ScaleX = (float)FbWidth  / RealWidth;
-                ScaleY = (float)FbHeight / RealHeight;
+                if (BufferQueue[Slot].Transform.HasFlag(HalTransform.Rotate90))
+                {
+                    ScaleY = (float)FbHeight / RealHeight;
+                    ScaleX = (float)FbWidth  / RealWidth;
 
-                OffsX = -(float)Crop.Left / Crop.Right;
-                OffsY = -(float)Crop.Top  / Crop.Bottom;
+                    OffsY = ((-(float)Crop.Left / Crop.Right)  + ScaleX - 1) * -XSign;
+                    OffsX = ((-(float)Crop.Top  / Crop.Bottom) + ScaleY - 1) * -YSign;
+                }
+                else
+                {
+                    ScaleX = (float)FbWidth  / RealWidth;
+                    ScaleY = (float)FbHeight / RealHeight;
 
-                OffsX += ScaleX - 1;
-                OffsY += ScaleY - 1;
+                    OffsX = ((-(float)Crop.Left / Crop.Right)  + ScaleX - 1) *  XSign;
+                    OffsY = ((-(float)Crop.Top  / Crop.Bottom) + ScaleY - 1) * -YSign;
+                }
             }
 
-            float Rotate = 0;
-
-            if (BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipX))
-            {
-                ScaleX = -ScaleX;
-            }
+            ScaleX *= XSign;
+            ScaleY *= YSign;
 
-            if (BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipY))
-            {
-                ScaleY = -ScaleY;
-            }
+            float Rotate = 0;
 
             if (BufferQueue[Slot].Transform.HasFlag(HalTransform.Rotate90))
             {

+ 6 - 1
Ryujinx.Core/OsHle/Svc/SvcThreadSync.cs

@@ -53,7 +53,12 @@ namespace Ryujinx.Core.OsHle.Svc
 
             Cv = Ns.Os.CondVars.GetOrAdd(CondVarAddress, Cv);
 
-            Cv.WaitForSignal(Thread);
+            if (!Cv.WaitForSignal(Thread))
+            {
+                ThreadState.X0 = (int)SvcResult.ErrTimeout;
+
+                return;
+            }
 
             M.WaitForLock(Thread, ThreadHandle);
 

+ 4 - 0
Ryujinx/Ui/GLScreen.cs

@@ -29,6 +29,10 @@ namespace Ryujinx
         {
             this.Ns       = Ns;
             this.Renderer = Renderer;
+
+            Location = new Point(
+                (DisplayDevice.Default.Width  / 2) - (Width  / 2),
+                (DisplayDevice.Default.Height / 2) - (Height / 2));
         }
 
         protected override void OnLoad(EventArgs e)