1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-10-01 12:30:00 +02:00

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

This commit is contained in:
gdkchan 2018-03-04 20:32:18 -03:00
parent 3edb66f389
commit 344fc8a55d
6 changed files with 46 additions and 24 deletions

View file

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

View file

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

View file

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

View file

@ -278,39 +278,45 @@ namespace Ryujinx.Core.OsHle.IpcServices.Android
int RealWidth = FbWidth; int RealWidth = FbWidth;
int RealHeight = FbHeight; 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 ScaleX = 1;
float ScaleY = 1; float ScaleY = 1;
float OffsX = 0; float OffsX = 0;
float OffsY = 0; float OffsY = 0;
if (Crop.Right != 0 && if (Crop.Right != 0 &&
Crop.Bottom != 0) Crop.Bottom != 0)
{ {
//Who knows if this is right, I was never good with math...
RealWidth = Crop.Right - Crop.Left; RealWidth = Crop.Right - Crop.Left;
RealHeight = Crop.Bottom - Crop.Top; RealHeight = Crop.Bottom - Crop.Top;
ScaleX = (float)FbWidth / RealWidth; if (BufferQueue[Slot].Transform.HasFlag(HalTransform.Rotate90))
ScaleY = (float)FbHeight / RealHeight; {
ScaleY = (float)FbHeight / RealHeight;
ScaleX = (float)FbWidth / RealWidth;
OffsX = -(float)Crop.Left / Crop.Right; OffsY = ((-(float)Crop.Left / Crop.Right) + ScaleX - 1) * -XSign;
OffsY = -(float)Crop.Top / Crop.Bottom; OffsX = ((-(float)Crop.Top / Crop.Bottom) + ScaleY - 1) * -YSign;
}
else
{
ScaleX = (float)FbWidth / RealWidth;
ScaleY = (float)FbHeight / RealHeight;
OffsX += ScaleX - 1; OffsX = ((-(float)Crop.Left / Crop.Right) + ScaleX - 1) * XSign;
OffsY += ScaleY - 1; OffsY = ((-(float)Crop.Top / Crop.Bottom) + ScaleY - 1) * -YSign;
}
} }
ScaleX *= XSign;
ScaleY *= YSign;
float Rotate = 0; float Rotate = 0;
if (BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipX))
{
ScaleX = -ScaleX;
}
if (BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipY))
{
ScaleY = -ScaleY;
}
if (BufferQueue[Slot].Transform.HasFlag(HalTransform.Rotate90)) if (BufferQueue[Slot].Transform.HasFlag(HalTransform.Rotate90))
{ {
Rotate = -MathF.PI * 0.5f; Rotate = -MathF.PI * 0.5f;

View file

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

View file

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