mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-04 03:36:26 +02:00
[Ryujinx.HLE] Address dotnet-format issues (#5380)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address or silence dotnet format IDE1006 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA2211 warnings * Address dotnet format CA1822 warnings * Address or silence dotnet format CA1069 warnings * Make dotnet format succeed in style mode * Address or silence dotnet format CA2211 warnings * Address review comments * Address dotnet format CA2208 warnings properly * Make ProcessResult readonly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add previously silenced warnings back I have no clue how these disappeared * Revert formatting changes for while and for-loops * Format if-blocks correctly * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix a few disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Use using declaration instead of block syntax * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Fix typo * Add trailing commas, use targeted new and use array initializer * Fix build issues * Fix remaining build issues * Remove SuppressMessage for CA1069 where possible * Address dotnet format issues * Address formatting issues Co-authored-by: Ac_K <acoustik666@gmail.com> * Add GetHashCode implementation for RenderingSurfaceInfo * Explicitly silence CA1822 for every affected method in Syscall * Address formatting issues in Demangler.cs * Address review feedback Co-authored-by: Ac_K <acoustik666@gmail.com> * Revert marking service methods as static * Next dotnet format pass * Address review feedback --------- Co-authored-by: Ac_K <acoustik666@gmail.com>
This commit is contained in:
parent
fec8291c17
commit
326749498b
1015 changed files with 8173 additions and 7615 deletions
|
@ -11,49 +11,47 @@ using System.Threading;
|
|||
|
||||
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
{
|
||||
using ResultCode = Ryujinx.HLE.HOS.Services.Vi.ResultCode;
|
||||
|
||||
class SurfaceFlinger : IConsumerListener, IDisposable
|
||||
{
|
||||
private const int TargetFps = 60;
|
||||
|
||||
private Switch _device;
|
||||
private readonly Switch _device;
|
||||
|
||||
private Dictionary<long, Layer> _layers;
|
||||
private readonly Dictionary<long, Layer> _layers;
|
||||
|
||||
private bool _isRunning;
|
||||
|
||||
private Thread _composerThread;
|
||||
private readonly Thread _composerThread;
|
||||
|
||||
private Stopwatch _chrono;
|
||||
private readonly Stopwatch _chrono;
|
||||
|
||||
private ManualResetEvent _event = new ManualResetEvent(false);
|
||||
private AutoResetEvent _nextFrameEvent = new AutoResetEvent(true);
|
||||
private readonly ManualResetEvent _event = new(false);
|
||||
private readonly AutoResetEvent _nextFrameEvent = new(true);
|
||||
private long _ticks;
|
||||
private long _ticksPerFrame;
|
||||
private long _spinTicks;
|
||||
private long _1msTicks;
|
||||
private readonly long _spinTicks;
|
||||
private readonly long _1msTicks;
|
||||
|
||||
private int _swapInterval;
|
||||
private int _swapIntervalDelay;
|
||||
|
||||
private readonly object Lock = new();
|
||||
private readonly object _lock = new();
|
||||
|
||||
public long RenderLayerId { get; private set; }
|
||||
|
||||
private class Layer
|
||||
{
|
||||
public int ProducerBinderId;
|
||||
public int ProducerBinderId;
|
||||
public IGraphicBufferProducer Producer;
|
||||
public BufferItemConsumer Consumer;
|
||||
public BufferQueueCore Core;
|
||||
public ulong Owner;
|
||||
public LayerState State;
|
||||
public BufferItemConsumer Consumer;
|
||||
public BufferQueueCore Core;
|
||||
public ulong Owner;
|
||||
public LayerState State;
|
||||
}
|
||||
|
||||
private class TextureCallbackInformation
|
||||
{
|
||||
public Layer Layer;
|
||||
public Layer Layer;
|
||||
public BufferItem Item;
|
||||
}
|
||||
|
||||
|
@ -65,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
_composerThread = new Thread(HandleComposition)
|
||||
{
|
||||
Name = "SurfaceFlinger.Composer"
|
||||
Name = "SurfaceFlinger.Composer",
|
||||
};
|
||||
|
||||
_chrono = new Stopwatch();
|
||||
|
@ -100,7 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
{
|
||||
layerId = 1;
|
||||
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
foreach (KeyValuePair<long, Layer> pair in _layers)
|
||||
{
|
||||
|
@ -118,7 +116,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
private void CreateLayerFromId(ulong pid, long layerId, LayerState initialState)
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.SurfaceFlinger, $"Creating layer {layerId}");
|
||||
|
||||
|
@ -132,16 +130,16 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
_layers.Add(layerId, new Layer
|
||||
{
|
||||
ProducerBinderId = HOSBinderDriverServer.RegisterBinderObject(producer),
|
||||
Producer = producer,
|
||||
Consumer = new BufferItemConsumer(_device, consumer, 0, -1, false, this),
|
||||
Core = core,
|
||||
Owner = pid,
|
||||
State = initialState
|
||||
Producer = producer,
|
||||
Consumer = new BufferItemConsumer(_device, consumer, 0, -1, false, this),
|
||||
Core = core,
|
||||
Owner = pid,
|
||||
State = initialState,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ResultCode OpenLayer(ulong pid, long layerId, out IBinder producer)
|
||||
public Vi.ResultCode OpenLayer(ulong pid, long layerId, out IBinder producer)
|
||||
{
|
||||
Layer layer = GetLayerByIdLocked(layerId);
|
||||
|
||||
|
@ -149,18 +147,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
{
|
||||
producer = null;
|
||||
|
||||
return ResultCode.InvalidArguments;
|
||||
return Vi.ResultCode.InvalidArguments;
|
||||
}
|
||||
|
||||
layer.State = LayerState.ManagedOpened;
|
||||
producer = layer.Producer;
|
||||
|
||||
return ResultCode.Success;
|
||||
return Vi.ResultCode.Success;
|
||||
}
|
||||
|
||||
public ResultCode CloseLayer(long layerId)
|
||||
public Vi.ResultCode CloseLayer(long layerId)
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
Layer layer = GetLayerByIdLocked(layerId);
|
||||
|
||||
|
@ -168,18 +166,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
{
|
||||
Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to close layer {layerId}");
|
||||
|
||||
return ResultCode.InvalidValue;
|
||||
return Vi.ResultCode.InvalidValue;
|
||||
}
|
||||
|
||||
CloseLayer(layerId, layer);
|
||||
|
||||
return ResultCode.Success;
|
||||
return Vi.ResultCode.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public ResultCode DestroyManagedLayer(long layerId)
|
||||
public Vi.ResultCode DestroyManagedLayer(long layerId)
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
Layer layer = GetLayerByIdLocked(layerId);
|
||||
|
||||
|
@ -187,14 +185,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
{
|
||||
Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy managed layer {layerId} (not found)");
|
||||
|
||||
return ResultCode.InvalidValue;
|
||||
return Vi.ResultCode.InvalidValue;
|
||||
}
|
||||
|
||||
if (layer.State != LayerState.ManagedClosed && layer.State != LayerState.ManagedOpened)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy managed layer {layerId} (permission denied)");
|
||||
|
||||
return ResultCode.PermissionDenied;
|
||||
return Vi.ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId);
|
||||
|
@ -204,13 +202,13 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
CloseLayer(layerId, layer);
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return Vi.ResultCode.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public ResultCode DestroyStrayLayer(long layerId)
|
||||
public Vi.ResultCode DestroyStrayLayer(long layerId)
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
Layer layer = GetLayerByIdLocked(layerId);
|
||||
|
||||
|
@ -218,14 +216,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
{
|
||||
Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (not found)");
|
||||
|
||||
return ResultCode.InvalidValue;
|
||||
return Vi.ResultCode.InvalidValue;
|
||||
}
|
||||
|
||||
if (layer.State != LayerState.Stray)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (permission denied)");
|
||||
|
||||
return ResultCode.PermissionDenied;
|
||||
return Vi.ResultCode.PermissionDenied;
|
||||
}
|
||||
|
||||
HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId);
|
||||
|
@ -235,7 +233,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
CloseLayer(layerId, layer);
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
return Vi.ResultCode.Success;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +261,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
public void SetRenderLayer(long layerId)
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
RenderLayerId = layerId;
|
||||
}
|
||||
|
@ -284,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
public IGraphicBufferProducer GetProducerByLayerId(long layerId)
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
Layer layer = GetLayerByIdLocked(layerId);
|
||||
|
||||
|
@ -365,7 +363,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
public void Compose()
|
||||
{
|
||||
lock (Lock)
|
||||
lock (_lock)
|
||||
{
|
||||
// TODO: support multilayers (& multidisplay ?)
|
||||
if (RenderLayerId == 0)
|
||||
|
@ -403,7 +401,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
|
||||
private void PostFrameBuffer(Layer layer, BufferItem item)
|
||||
{
|
||||
int frameBufferWidth = item.GraphicBuffer.Object.Width;
|
||||
int frameBufferWidth = item.GraphicBuffer.Object.Width;
|
||||
int frameBufferHeight = item.GraphicBuffer.Object.Height;
|
||||
|
||||
int nvMapHandle = item.GraphicBuffer.Object.Buffer.Surfaces[0].NvMapHandle;
|
||||
|
@ -434,9 +432,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
bool flipY = item.Transform.HasFlag(NativeWindowTransform.FlipY);
|
||||
|
||||
AspectRatio aspectRatio = _device.Configuration.AspectRatio;
|
||||
bool isStretched = aspectRatio == AspectRatio.Stretched;
|
||||
bool isStretched = aspectRatio == AspectRatio.Stretched;
|
||||
|
||||
ImageCrop crop = new ImageCrop(
|
||||
ImageCrop crop = new(
|
||||
cropRect.Left,
|
||||
cropRect.Right,
|
||||
cropRect.Top,
|
||||
|
@ -447,10 +445,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
aspectRatio.ToFloatX(),
|
||||
aspectRatio.ToFloatY());
|
||||
|
||||
TextureCallbackInformation textureCallbackInformation = new TextureCallbackInformation
|
||||
TextureCallbackInformation textureCallbackInformation = new()
|
||||
{
|
||||
Layer = layer,
|
||||
Item = item
|
||||
Item = item,
|
||||
};
|
||||
|
||||
if (_device.Gpu.Window.EnqueueFrameThreadSafe(
|
||||
|
@ -543,6 +541,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
_device.Statistics.RecordGameFrameTime();
|
||||
}
|
||||
|
||||
public void OnBuffersReleased() {}
|
||||
public void OnBuffersReleased() { }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue