mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-03-14 17:00:17 +00:00
Limit number of events that can be retrieved from GetDisplayVSyncEvent
This commit is contained in:
parent
747081d2c7
commit
d2fd7c1afa
5 changed files with 24 additions and 13 deletions
|
@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
|
||||
if (serviceType != ViServiceType.Application)
|
||||
{
|
||||
return ResultCode.InvalidRange;
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
MakeObject(context, new IApplicationDisplayService(serviceType));
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
|
||||
if (serviceType != ViServiceType.Manager)
|
||||
{
|
||||
return ResultCode.InvalidRange;
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
MakeObject(context, new IApplicationDisplayService(serviceType));
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
|
||||
if (serviceType != ViServiceType.System)
|
||||
{
|
||||
return ResultCode.InvalidRange;
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
MakeObject(context, new IApplicationDisplayService(serviceType));
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
|
||||
InvalidArguments = (1 << ErrorCodeShift) | ModuleId,
|
||||
InvalidLayerSize = (4 << ErrorCodeShift) | ModuleId,
|
||||
InvalidRange = (5 << ErrorCodeShift) | ModuleId,
|
||||
PermissionDenied = (5 << ErrorCodeShift) | ModuleId,
|
||||
InvalidScalingMode = (6 << ErrorCodeShift) | ModuleId,
|
||||
InvalidValue = (7 << ErrorCodeShift) | ModuleId,
|
||||
AlreadyOpened = (9 << ErrorCodeShift) | ModuleId
|
||||
|
|
|
@ -22,8 +22,13 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
{
|
||||
private readonly ViServiceType _serviceType;
|
||||
|
||||
private readonly List<DisplayInfo> _displayInfo;
|
||||
private readonly Dictionary<ulong, DisplayInfo> _openDisplayInfo;
|
||||
private class DisplayState
|
||||
{
|
||||
public int RetrievedEventsCount;
|
||||
}
|
||||
|
||||
private readonly List<DisplayInfo> _displayInfo;
|
||||
private readonly Dictionary<ulong, DisplayState> _openDisplayInfo;
|
||||
|
||||
private int _vsyncEventHandle;
|
||||
|
||||
|
@ -31,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
{
|
||||
_serviceType = serviceType;
|
||||
_displayInfo = new List<DisplayInfo>();
|
||||
_openDisplayInfo = new Dictionary<ulong, DisplayInfo>();
|
||||
_openDisplayInfo = new Dictionary<ulong, DisplayState>();
|
||||
|
||||
void AddDisplayInfo(string name, bool layerLimitEnabled, ulong layerLimitMax, ulong width, ulong height)
|
||||
{
|
||||
|
@ -64,7 +69,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
// FIXME: Should be _serviceType != ViServiceType.Application but guests crashes if we do this check.
|
||||
if (_serviceType > ViServiceType.System)
|
||||
{
|
||||
return ResultCode.InvalidRange;
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
MakeObject(context, new HOSBinderDriverServer());
|
||||
|
@ -79,7 +84,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
// FIXME: Should be _serviceType == ViServiceType.System but guests crashes if we do this check.
|
||||
if (_serviceType > ViServiceType.System)
|
||||
{
|
||||
return ResultCode.InvalidRange;
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
MakeObject(context, new ISystemDisplayService(this));
|
||||
|
@ -93,7 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
{
|
||||
if (_serviceType > ViServiceType.System)
|
||||
{
|
||||
return ResultCode.InvalidRange;
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
MakeObject(context, new IManagerDisplayService(this));
|
||||
|
@ -107,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
{
|
||||
if (_serviceType > ViServiceType.System)
|
||||
{
|
||||
return ResultCode.InvalidRange;
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
MakeObject(context, new HOSBinderDriverServer());
|
||||
|
@ -174,7 +179,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
return ResultCode.InvalidValue;
|
||||
}
|
||||
|
||||
if (!_openDisplayInfo.TryAdd((ulong)displayId, _displayInfo[displayId]))
|
||||
if (!_openDisplayInfo.TryAdd((ulong)displayId, new DisplayState()))
|
||||
{
|
||||
return ResultCode.AlreadyOpened;
|
||||
}
|
||||
|
@ -454,11 +459,16 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
{
|
||||
ulong displayId = context.RequestData.ReadUInt64();
|
||||
|
||||
if (!_openDisplayInfo.ContainsKey(displayId))
|
||||
if (!_openDisplayInfo.TryGetValue(displayId, out DisplayState displayState))
|
||||
{
|
||||
return ResultCode.InvalidValue;
|
||||
}
|
||||
|
||||
if (displayState.RetrievedEventsCount > 0)
|
||||
{
|
||||
return ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
if (_vsyncEventHandle == 0)
|
||||
{
|
||||
if (context.Process.HandleTable.GenerateHandle(context.Device.System.VsyncEvent.ReadableEvent, out _vsyncEventHandle) != KernelResult.Success)
|
||||
|
@ -467,6 +477,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||
}
|
||||
}
|
||||
|
||||
displayState.RetrievedEventsCount++;
|
||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_vsyncEventHandle);
|
||||
|
||||
return ResultCode.Success;
|
||||
|
|
Loading…
Reference in a new issue