mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-16 06:23:17 +01: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:
parent
3edb66f389
commit
344fc8a55d
@ -7,7 +7,6 @@ using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using System.Threading;
|
||||
|
||||
namespace ChocolArm64
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -278,39 +278,45 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
ScaleX *= XSign;
|
||||
ScaleY *= YSign;
|
||||
|
||||
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))
|
||||
{
|
||||
Rotate = -MathF.PI * 0.5f;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user