diff options
| author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-07-16 19:31:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-16 19:31:14 +0200 |
| commit | 326749498bed4360e5a4b11fc67d5ec7cb9a3076 (patch) | |
| tree | ae21fb26f99b401ca4e9efaab72b679a81c22369 /src/Ryujinx.HLE/HOS/Services/Nv | |
| parent | fec8291c17fa106c28f58b56419e90d49a41a1ea (diff) | |
[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>
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Nv')
58 files changed, 391 insertions, 397 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs index bb609fa4..371edbec 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv { public MemoryManager Smmu { get; } public NvMemoryAllocator MemoryAllocator { get; } - public Host1xDevice Host1x { get;} + public Host1xDevice Host1x { get; } public Host1xContext(GpuContext gpu, ulong pid) { @@ -29,4 +29,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv Host1x.Dispose(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs index dffe8783..22d0aacc 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvDebugFSServices.cs @@ -5,4 +5,4 @@ { public INvDrvDebugFSServices(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index 1d075d43..a0df66d0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -25,13 +25,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv [Service("nvdrv:t")] class INvDrvServices : IpcService { - private static readonly List<string> _deviceFileDebugRegistry = new List<string>() + private static readonly List<string> _deviceFileDebugRegistry = new() { "/dev/nvhost-dbg-gpu", - "/dev/nvhost-prof-gpu" + "/dev/nvhost-prof-gpu", }; - private static readonly Dictionary<string, Type> _deviceFileRegistry = new Dictionary<string, Type>() + private static readonly Dictionary<string, Type> _deviceFileRegistry = new() { { "/dev/nvmap", typeof(NvMapDeviceFile) }, { "/dev/nvhost-ctrl", typeof(NvHostCtrlDeviceFile) }, @@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv { "/dev/nvhost-prof-gpu", typeof(NvHostProfGpuDeviceFile) }, }; - public static IdDictionary DeviceFileIdRegistry = new IdDictionary(); + public static IdDictionary DeviceFileIdRegistry = new(); private IVirtualMemoryManager _clientMemory; private ulong _owner; @@ -55,7 +55,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv private bool _transferMemInitialized = false; // TODO: This should call set:sys::GetDebugModeFlag - private bool _debugModeEnabled = false; + private readonly bool _debugModeEnabled = false; public INvDrvServices(ServiceCtx context) : base(context.Device.System.NvDrvServer) { @@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (_deviceFileRegistry.TryGetValue(path, out Type deviceFileClass)) { - ConstructorInfo constructor = deviceFileClass.GetConstructor(new Type[] { typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong) }); + ConstructorInfo constructor = deviceFileClass.GetConstructor(new[] { typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong) }); NvDeviceFile deviceFile = (NvDeviceFile)constructor.Invoke(new object[] { context, _clientMemory, _owner }); @@ -91,13 +91,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv private NvResult GetIoctlArgument(ServiceCtx context, NvIoctl ioctlCommand, out Span<byte> arguments) { - (ulong inputDataPosition, ulong inputDataSize) = context.Request.GetBufferType0x21(0); + (ulong inputDataPosition, ulong inputDataSize) = context.Request.GetBufferType0x21(0); +#pragma warning disable IDE0059 // Remove unnecessary value assignment (ulong outputDataPosition, ulong outputDataSize) = context.Request.GetBufferType0x22(0); +#pragma warning restore IDE0059 NvIoctl.Direction ioctlDirection = ioctlCommand.DirectionValue; - uint ioctlSize = ioctlCommand.Size; + uint ioctlSize = ioctlCommand.Size; - bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0; + bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0; bool isWrite = (ioctlDirection & NvIoctl.Direction.Write) != 0; if ((isWrite && ioctlSize > outputDataSize) || (isRead && ioctlSize > inputDataSize)) @@ -186,53 +188,29 @@ namespace Ryujinx.HLE.HOS.Services.Nv return NvResult.Success; } - private static NvResult ConvertInternalErrorCode(NvInternalResult errorCode) + private NvResult ConvertInternalErrorCode(NvInternalResult errorCode) { - switch (errorCode) + return errorCode switch { - case NvInternalResult.Success: - return NvResult.Success; - case NvInternalResult.Unknown0x72: - return NvResult.AlreadyAllocated; - case NvInternalResult.TimedOut: - case NvInternalResult.TryAgain: - case NvInternalResult.Interrupted: - return NvResult.Timeout; - case NvInternalResult.InvalidAddress: - return NvResult.InvalidAddress; - case NvInternalResult.NotSupported: - case NvInternalResult.Unknown0x18: - return NvResult.NotSupported; - case NvInternalResult.InvalidState: - return NvResult.InvalidState; - case NvInternalResult.ReadOnlyAttribute: - return NvResult.ReadOnlyAttribute; - case NvInternalResult.NoSpaceLeft: - case NvInternalResult.FileTooBig: - return NvResult.InvalidSize; - case NvInternalResult.FileTableOverflow: - case NvInternalResult.BadFileNumber: - return NvResult.FileOperationFailed; - case NvInternalResult.InvalidInput: - return NvResult.InvalidValue; - case NvInternalResult.NotADirectory: - return NvResult.DirectoryOperationFailed; - case NvInternalResult.Busy: - return NvResult.Busy; - case NvInternalResult.BadAddress: - return NvResult.InvalidAddress; - case NvInternalResult.AccessDenied: - case NvInternalResult.OperationNotPermitted: - return NvResult.AccessDenied; - case NvInternalResult.OutOfMemory: - return NvResult.InsufficientMemory; - case NvInternalResult.DeviceNotFound: - return NvResult.ModuleNotPresent; - case NvInternalResult.IoError: - return NvResult.ResourceError; - default: - return NvResult.IoctlFailed; - } + NvInternalResult.Success => NvResult.Success, + NvInternalResult.Unknown0x72 => NvResult.AlreadyAllocated, + NvInternalResult.TimedOut or NvInternalResult.TryAgain or NvInternalResult.Interrupted => NvResult.Timeout, + NvInternalResult.InvalidAddress => NvResult.InvalidAddress, + NvInternalResult.NotSupported or NvInternalResult.Unknown0x18 => NvResult.NotSupported, + NvInternalResult.InvalidState => NvResult.InvalidState, + NvInternalResult.ReadOnlyAttribute => NvResult.ReadOnlyAttribute, + NvInternalResult.NoSpaceLeft or NvInternalResult.FileTooBig => NvResult.InvalidSize, + NvInternalResult.FileTableOverflow or NvInternalResult.BadFileNumber => NvResult.FileOperationFailed, + NvInternalResult.InvalidInput => NvResult.InvalidValue, + NvInternalResult.NotADirectory => NvResult.DirectoryOperationFailed, + NvInternalResult.Busy => NvResult.Busy, + NvInternalResult.BadAddress => NvResult.InvalidAddress, + NvInternalResult.AccessDenied or NvInternalResult.OperationNotPermitted => NvResult.AccessDenied, + NvInternalResult.OutOfMemory => NvResult.InsufficientMemory, + NvInternalResult.DeviceNotFound => NvResult.ModuleNotPresent, + NvInternalResult.IoError => NvResult.ResourceError, + _ => NvResult.IoctlFailed, + }; } [CommandCmif(0)] @@ -240,7 +218,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv public ResultCode Open(ServiceCtx context) { NvResult errorCode = EnsureInitialized(); - int fd = -1; + int fd = -1; if (errorCode == NvResult.Success) { @@ -266,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>(); errorCode = GetIoctlArgument(context, ioctlCommand, out Span<byte> arguments); @@ -328,8 +306,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv // Initialize(u32 transfer_memory_size, handle<copy, process> current_process, handle<copy, transfer_memory> transfer_memory) -> u32 error_code public ResultCode Initialize(ServiceCtx context) { - long transferMemSize = context.RequestData.ReadInt64(); - int transferMemHandle = context.Request.HandleDesc.ToCopy[1]; +#pragma warning disable IDE0059 // Remove unnecessary value assignment + long transferMemSize = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 + int transferMemHandle = context.Request.HandleDesc.ToCopy[1]; // TODO: When transfer memory will be implemented, this could be removed. _transferMemInitialized = true; @@ -357,7 +337,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); uint eventId = context.RequestData.ReadUInt32(); errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile); @@ -393,9 +373,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); - uint argument = context.RequestData.ReadUInt32(); - int sharedMemoryHandle = context.Request.HandleDesc.ToCopy[0]; + int fd = context.RequestData.ReadInt32(); + uint argument = context.RequestData.ReadUInt32(); + int sharedMemoryHandle = context.Request.HandleDesc.ToCopy[0]; errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile); @@ -418,12 +398,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (_transferMemInitialized) { // TODO: Populate values when more RE will be done. - NvStatus nvStatus = new NvStatus + NvStatus nvStatus = new() { MemoryValue1 = 0, // GetMemStats(transfer_memory + 0x60, 3) MemoryValue2 = 0, // GetMemStats(transfer_memory + 0x60, 5) MemoryValue3 = 0, // transfer_memory + 0x78 - MemoryValue4 = 0 // transfer_memory + 0x80 + MemoryValue4 = 0, // transfer_memory + 0x80 }; context.ResponseData.WriteStruct(nvStatus); @@ -450,7 +430,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv // SetClientPID(u64, pid) -> u32 error_code public ResultCode SetClientPid(ServiceCtx context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment long pid = context.RequestData.ReadInt64(); +#pragma warning restore IDE0059 context.ResponseData.Write(0); @@ -481,7 +463,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>(); (ulong inlineInBufferPosition, ulong inlineInBufferSize) = context.Request.GetBufferType0x21(1); @@ -492,7 +474,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv context.Memory.Read(inlineInBufferPosition, temp); - Span<byte> inlineInBuffer = new Span<byte>(temp); + Span<byte> inlineInBuffer = new(temp); if (errorCode == NvResult.Success) { @@ -530,7 +512,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - int fd = context.RequestData.ReadInt32(); + int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct<NvIoctl>(); (ulong inlineOutBufferPosition, ulong inlineOutBufferSize) = context.Request.GetBufferType0x22(1); @@ -541,7 +523,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv context.Memory.Read(inlineOutBufferPosition, temp); - Span<byte> inlineOutBuffer = new Span<byte>(temp); + Span<byte> inlineOutBuffer = new(temp); if (errorCode == NvResult.Success) { @@ -595,4 +577,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv DeviceFileIdRegistry.Clear(); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs index 7bf99ed1..2134c026 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemControl.cs @@ -5,4 +5,4 @@ { public INvGemControl(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs index ff3774da..ecbbe222 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvGemCoreDump.cs @@ -5,4 +5,4 @@ { public INvGemCoreDump(ServiceCtx context) { } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs index 9568fc84..3eaf8a91 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs @@ -10,14 +10,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices abstract class NvDeviceFile { public readonly ServiceCtx Context; - public readonly ulong Owner; + public readonly ulong Owner; public string Path; public NvDeviceFile(ServiceCtx context, ulong owner) { Context = context; - Owner = owner; + Owner = owner; } public virtual NvInternalResult QueryEvent(out int eventHandle, uint eventId) diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs index 0e0fe7f2..db460429 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs @@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu private const uint SmallPageSize = 0x1000; private const uint BigPageSize = 0x10000; - private static readonly uint[] _pageSizes = new uint[] { SmallPageSize, BigPageSize }; + private static readonly uint[] _pageSizes = { SmallPageSize, BigPageSize }; private const ulong SmallRegionLimit = 0x400000000UL; // 16 GiB private const ulong DefaultUserSize = 1UL << 37; @@ -32,10 +32,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu } } - private static readonly VmRegion[] _vmRegions = new VmRegion[] - { + private static readonly VmRegion[] _vmRegions = { new VmRegion((ulong)BigPageSize << 16, SmallRegionLimit), - new VmRegion(SmallRegionLimit, DefaultUserSize) + new VmRegion(SmallRegionLimit, DefaultUserSize), }; private readonly AddressSpaceContext _asContext; diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs index ab9d798e..36aa10f3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceContext.cs @@ -8,24 +8,24 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types private class Range { public ulong Start { get; } - public ulong End { get; } + public ulong End { get; } public Range(ulong address, ulong size) { Start = address; - End = size + Start; + End = size + Start; } } private class MappedMemory : Range { public ulong PhysicalAddress { get; } - public bool VaAllocated { get; } + public bool VaAllocated { get; } public MappedMemory(ulong address, ulong size, ulong physicalAddress, bool vaAllocated) : base(address, size) { PhysicalAddress = physicalAddress; - VaAllocated = vaAllocated; + VaAllocated = vaAllocated; } } @@ -38,7 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types { Gmm = gmm; - _maps = new SortedList<ulong, Range>(); + _maps = new SortedList<ulong, Range>(); _reservations = new SortedList<ulong, Range>(); } @@ -123,9 +123,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types return _reservations.Remove(gpuVa); } - private static Range BinarySearch(SortedList<ulong, Range> list, ulong address) + private Range BinarySearch(SortedList<ulong, Range> list, ulong address) { - int left = 0; + int left = 0; int right = list.Count - 1; while (left <= right) @@ -154,11 +154,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types return null; } - private static Range BinarySearchLt(SortedList<ulong, Range> list, ulong address) + private Range BinarySearchLt(SortedList<ulong, Range> list, ulong address) { Range ltRg = null; - int left = 0; + int left = 0; int right = list.Count - 1; while (left <= right) diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs index 611cf78b..0627d56f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AddressSpaceFlags.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types [Flags] enum AddressSpaceFlags : uint { - FixedOffset = 1, + FixedOffset = 1, RemapSubRange = 0x100, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs index d6dbbc26..c9d7724e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/AllocSpaceArguments.cs @@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types [StructLayout(LayoutKind.Sequential)] struct AllocSpaceArguments { - public uint Pages; - public uint PageSize; + public uint Pages; + public uint PageSize; public AddressSpaceFlags Flags; - public uint Padding; - public ulong Offset; + public uint Padding; + public ulong Offset; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs index b25d295a..56e9028e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/FreeSpaceArguments.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types struct FreeSpaceArguments { public ulong Offset; - public uint Pages; - public uint PageSize; + public uint Pages; + public uint PageSize; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs index 882bda59..34b80bd3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/InitializeExArguments.cs @@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types [StructLayout(LayoutKind.Sequential)] struct InitializeExArguments { - public uint Flags; - public int AsFd; - public uint BigPageSize; - public uint Reserved; + public uint Flags; + public int AsFd; + public uint BigPageSize; + public uint Reserved; public ulong Unknown0; public ulong Unknown1; public ulong Unknown2; diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs index 278793a0..fdeff9f8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/MapBufferExArguments.cs @@ -6,11 +6,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types struct MapBufferExArguments { public AddressSpaceFlags Flags; - public int Kind; - public int NvMapHandle; - public int PageSize; - public ulong BufferOffset; - public ulong MappingSize; - public ulong Offset; + public int Kind; + public int NvMapHandle; + public int PageSize; + public ulong BufferOffset; + public ulong MappingSize; + public ulong Offset; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs index bc149d42..1fb224ff 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/RemapArguments.cs @@ -7,9 +7,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types { public ushort Flags; public ushort Kind; - public int NvMapHandle; - public uint MapOffset; - public uint GpuOffset; - public uint Pages; + public int NvMapHandle; + public uint MapOffset; + public uint GpuOffset; + public uint Pages; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs index 8fc4646e..46a9659d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/Types/UnmapBufferArguments.cs @@ -2,7 +2,7 @@ { struct UnmapBufferArguments { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public ulong Offset; #pragma warning restore CS0649 } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs index 87a06bd3..59578775 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/ChannelInitialization.cs @@ -1358,4 +1358,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel channel.Write(ClassId.Twod, 0x24C, 0x100); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs index 9f16a280..bd2c5e4d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs @@ -19,9 +19,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private const uint MaxModuleSyncpoint = 16; +#pragma warning disable IDE0052 // Remove unread private member private uint _timeout; private uint _submitTimeout; private uint _timeslice; +#pragma warning restore IDE0052 private readonly Switch _device; @@ -34,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public enum ResourcePolicy { Device, - Channel + Channel, } protected static uint[] DeviceSyncpoints = new uint[MaxModuleSyncpoint]; @@ -47,14 +49,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public NvHostChannelDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { - _device = context.Device; - _memory = memory; - _timeout = 3000; + _device = context.Device; + _memory = memory; + _timeout = 3000; _submitTimeout = 0; - _timeslice = 0; + _timeslice = 0; _host1xContext = GetHost1XContext(context.Device.Gpu, owner); - _contextId = _host1xContext.Host1x.CreateContext(); - Channel = _device.Gpu.CreateChannel(); + _contextId = _host1xContext.Host1x.CreateContext(); + Channel = _device.Gpu.CreateChannel(); ChannelInitialization.InitializeState(Channel); @@ -143,12 +145,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult Submit(Span<byte> arguments) { - SubmitArguments submitHeader = GetSpanAndSkip<SubmitArguments>(ref arguments, 1)[0]; - Span<CommandBuffer> commandBuffers = GetSpanAndSkip<CommandBuffer>(ref arguments, submitHeader.CmdBufsCount); - Span<Reloc> relocs = GetSpanAndSkip<Reloc>(ref arguments, submitHeader.RelocsCount); - Span<uint> relocShifts = GetSpanAndSkip<uint>(ref arguments, submitHeader.RelocsCount); - Span<SyncptIncr> syncptIncrs = GetSpanAndSkip<SyncptIncr>(ref arguments, submitHeader.SyncptIncrsCount); - Span<uint> fenceThresholds = GetSpanAndSkip<uint>(ref arguments, submitHeader.FencesCount); + SubmitArguments submitHeader = GetSpanAndSkip<SubmitArguments>(ref arguments, 1)[0]; + Span<CommandBuffer> commandBuffers = GetSpanAndSkip<CommandBuffer>(ref arguments, submitHeader.CmdBufsCount); +#pragma warning disable IDE0059 // Remove unnecessary value assignment + Span<Reloc> relocs = GetSpanAndSkip<Reloc>(ref arguments, submitHeader.RelocsCount); + Span<uint> relocShifts = GetSpanAndSkip<uint>(ref arguments, submitHeader.RelocsCount); +#pragma warning restore IDE0059 + Span<SyncptIncr> syncptIncrs = GetSpanAndSkip<SyncptIncr>(ref arguments, submitHeader.SyncptIncrsCount); + Span<uint> fenceThresholds = GetSpanAndSkip<uint>(ref arguments, submitHeader.FencesCount); lock (_device) { @@ -176,9 +180,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private Span<T> GetSpanAndSkip<T>(ref Span<byte> arguments, int count) where T : unmanaged { - Span<T> output = MemoryMarshal.Cast<byte, T>(arguments).Slice(0, count); + Span<T> output = MemoryMarshal.Cast<byte, T>(arguments)[..count]; - arguments = arguments.Slice(Unsafe.SizeOf<T>() * count); + arguments = arguments[(Unsafe.SizeOf<T>() * count)..]; return output; } @@ -227,9 +231,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult MapCommandBuffer(Span<byte> arguments) { - int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); - MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; - Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries); + int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); + MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; + Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments[headerSize..])[..commandBufferHeader.NumEntries]; foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries) { @@ -269,9 +273,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult UnmapCommandBuffer(Span<byte> arguments) { - int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); - MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; - Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries); + int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>(); + MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0]; + Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments[headerSize..])[..commandBufferHeader.NumEntries]; foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries) { @@ -320,9 +324,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult SubmitGpfifo(Span<byte> arguments) { - int headerSize = Unsafe.SizeOf<SubmitGpfifoArguments>(); + int headerSize = Unsafe.SizeOf<SubmitGpfifoArguments>(); SubmitGpfifoArguments gpfifoSubmissionHeader = MemoryMarshal.Cast<byte, SubmitGpfifoArguments>(arguments)[0]; - Span<ulong> gpfifoEntries = MemoryMarshal.Cast<byte, ulong>(arguments.Slice(headerSize)).Slice(0, gpfifoSubmissionHeader.NumEntries); + Span<ulong> gpfifoEntries = MemoryMarshal.Cast<byte, ulong>(arguments[headerSize..])[..gpfifoSubmissionHeader.NumEntries]; return SubmitGpfifo(ref gpfifoSubmissionHeader, gpfifoEntries); } @@ -473,7 +477,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel return ChannelSyncpoints[index]; } - public static uint GetSyncpointDevice(NvHostSyncpt syncpointManager, uint index, bool isClientManaged) + public uint GetSyncpointDevice(NvHostSyncpt syncpointManager, uint index, bool isClientManaged) { if (DeviceSyncpoints[index] != 0) { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs index f33cc460..5a1d1a68 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostGpuDeviceFile.cs @@ -8,9 +8,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel { internal class NvHostGpuDeviceFile : NvHostChannelDeviceFile { - private KEvent _smExceptionBptIntReportEvent; - private KEvent _smExceptionBptPauseReportEvent; - private KEvent _errorNotifierEvent; +#pragma warning disable IDE0052 // Remove unread private member + private readonly KEvent _smExceptionBptIntReportEvent; + private readonly KEvent _smExceptionBptPauseReportEvent; + private readonly KEvent _errorNotifierEvent; +#pragma warning restore IDE0052 private int _smExceptionBptIntReportEventHandle; private int _smExceptionBptPauseReportEventHandle; @@ -18,14 +20,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public NvHostGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, memory, owner) { - _smExceptionBptIntReportEvent = CreateEvent(context, out _smExceptionBptIntReportEventHandle); + _smExceptionBptIntReportEvent = CreateEvent(context, out _smExceptionBptIntReportEventHandle); _smExceptionBptPauseReportEvent = CreateEvent(context, out _smExceptionBptPauseReportEventHandle); - _errorNotifierEvent = CreateEvent(context, out _errorNotifierEventHandle); + _errorNotifierEvent = CreateEvent(context, out _errorNotifierEventHandle); } - private static KEvent CreateEvent(ServiceCtx context, out int handle) + private KEvent CreateEvent(ServiceCtx context, out int handle) { - KEvent evnt = new KEvent(context.Device.System.KernelContext); + KEvent evnt = new(context.Device.System.KernelContext); if (context.Process.HandleTable.GenerateHandle(evnt.ReadableEvent, out handle) != Result.Success) { @@ -55,22 +57,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel public override NvInternalResult QueryEvent(out int eventHandle, uint eventId) { // TODO: accurately represent and implement those events. - switch (eventId) + eventHandle = eventId switch { - case 0x1: - eventHandle = _smExceptionBptIntReportEventHandle; - break; - case 0x2: - eventHandle = _smExceptionBptPauseReportEventHandle; - break; - case 0x3: - eventHandle = _errorNotifierEventHandle; - break; - default: - eventHandle = 0; - break; - } - + 0x1 => _smExceptionBptIntReportEventHandle, + 0x2 => _smExceptionBptPauseReportEventHandle, + 0x3 => _errorNotifierEventHandle, + _ => 0, + }; return eventHandle != 0 ? NvInternalResult.Success : NvInternalResult.InvalidInput; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs index 8e5a1523..37577a5f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocGpfifoExArguments.cs @@ -6,12 +6,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential)] struct AllocGpfifoExArguments { - public uint NumEntries; - public uint NumJobs; - public uint Flags; + public uint NumEntries; + public uint NumJobs; + public uint Flags; public NvFence Fence; - public uint Reserved1; - public uint Reserved2; - public uint Reserved3; + public uint Reserved1; + public uint Reserved2; + public uint Reserved3; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs index fae91622..1ffbb68f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/AllocObjCtxArguments.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential)] struct AllocObjCtxArguments { - public uint ClassNumber; - public uint Flags; + public uint ClassNumber; + public uint Flags; public ulong ObjectId; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs index 6a7e3da8..0777e646 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/MapCommandBufferArguments.cs @@ -12,10 +12,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential, Pack = 1)] struct MapCommandBufferArguments { - public int NumEntries; - public int DataAddress; // Ignored by the driver. - public bool AttachHostChDas; - public byte Padding1; + public int NumEntries; + public int DataAddress; // Ignored by the driver. + public bool AttachHostChDas; + public byte Padding1; public short Padding2; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs index 8e2c6ca3..177f483f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannel.cs @@ -2,10 +2,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel { class NvChannel { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public int Timeout; public int SubmitTimeout; public int Timeslice; #pragma warning restore CS0649 } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs index 4112a9fc..c267e2df 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/NvChannelPriority.cs @@ -2,8 +2,8 @@ { enum NvChannelPriority : uint { - Low = 50, + Low = 50, Medium = 100, - High = 150 + High = 150, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs index 1aba53ca..7e5a5e96 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SetErrorNotifierArguments.cs @@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types { public ulong Offset; public ulong Size; - public uint Mem; - public uint Reserved; + public uint Mem; + public uint Reserved; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs index a10abd4b..1bb08da1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoArguments.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types [StructLayout(LayoutKind.Sequential)] struct SubmitGpfifoArguments { - public long Address; - public int NumEntries; + public long Address; + public int NumEntries; public SubmitGpfifoFlags Flags; - public NvFence Fence; + public NvFence Fence; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs index d81fd386..1f060980 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/SubmitGpfifoFlags.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types enum SubmitGpfifoFlags : uint { None, - FenceWait = 1 << 0, - FenceIncrement = 1 << 1, - HwFormat = 1 << 2, - SuppressWfi = 1 << 4, + FenceWait = 1 << 0, + FenceIncrement = 1 << 1, + HwFormat = 1 << 2, + SuppressWfi = 1 << 4, IncrementWithValue = 1 << 8, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs index 19a997f4..71b12466 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/Types/ZcullBindArguments.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types struct ZcullBindArguments { public ulong GpuVirtualAddress; - public uint Mode; - public uint Reserved; + public uint Mode; + public uint Reserved; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs index f130c455..6142611e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs @@ -14,9 +14,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl { public const int EventsCount = 64; - private bool _isProductionMode; - private Switch _device; - private NvHostEvent[] _events; + private readonly bool _isProductionMode; + private readonly Switch _device; + private readonly NvHostEvent[] _events; public NvHostCtrlDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs index 16f970e8..84f678ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/EventWaitArguments.cs @@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types struct EventWaitArguments { public NvFence Fence; - public int Timeout; - public uint Value; + public int Timeout; + public uint Value; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs index 3ee318a3..a1400f8e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/GetConfigurationArguments.cs @@ -11,14 +11,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types public static GetConfigurationArguments FromSpan(Span<byte> span) { - string domain = Encoding.ASCII.GetString(span.Slice(0, 0x41)); + string domain = Encoding.ASCII.GetString(span[..0x41]); string parameter = Encoding.ASCII.GetString(span.Slice(0x41, 0x41)); - GetConfigurationArguments result = new GetConfigurationArguments + GetConfigurationArguments result = new() { - Domain = domain.Substring(0, domain.IndexOf('\0')), - Parameter = parameter.Substring(0, parameter.IndexOf('\0')), - Configuration = span.Slice(0x82, 0x101).ToArray() + Domain = domain[..domain.IndexOf('\0')], + Parameter = parameter[..parameter.IndexOf('\0')], + Configuration = span.Slice(0x82, 0x101).ToArray(), }; return result; @@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types public void CopyTo(Span<byte> span) { - Encoding.ASCII.GetBytes(Domain + '\0').CopyTo(span.Slice(0, 0x41)); + Encoding.ASCII.GetBytes(Domain + '\0').CopyTo(span[..0x41]); Encoding.ASCII.GetBytes(Parameter + '\0').CopyTo(span.Slice(0x41, 0x41)); Configuration.CopyTo(span.Slice(0x82, 0x101)); } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs index 383fb3fb..8f851f37 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs @@ -12,17 +12,19 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl { class NvHostEvent { - public NvFence Fence; + public NvFence Fence; public NvHostEventState State; - public KEvent Event; - public int EventHandle; + public KEvent Event; + public int EventHandle; - private uint _eventId; - private NvHostSyncpt _syncpointManager; + private readonly uint _eventId; +#pragma warning disable IDE0052 // Remove unread private member + private readonly NvHostSyncpt _syncpointManager; +#pragma warning restore IDE0052 private SyncpointWaiterHandle _waiterInformation; private NvFence _previousFailingFence; - private uint _failingCount; + private uint _failingCount; public readonly object Lock = new(); @@ -54,9 +56,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl private void ResetFailingState() { - _previousFailingFence.Id = NvFence.InvalidSyncPointId; + _previousFailingFence.Id = NvFence.InvalidSyncPointId; _previousFailingFence.Value = 0; - _failingCount = 0; + _failingCount = 0; } private void Signal() @@ -182,4 +184,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs index c7b4bc9f..57c99d61 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEventState.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl { enum NvHostEventState { - Available = 0, - Waiting = 1, + Available = 0, + Waiting = 1, Cancelling = 2, - Signaling = 3, - Signaled = 4, - Cancelled = 5 + Signaling = 3, + Signaled = 4, + Cancelled = 5, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs index 1b842aa1..9c6d025e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs @@ -10,22 +10,22 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl public const int VBlank0SyncpointId = 26; public const int VBlank1SyncpointId = 27; - private int[] _counterMin; - private int[] _counterMax; - private bool[] _clientManaged; - private bool[] _assigned; + private readonly int[] _counterMin; + private readonly int[] _counterMax; + private readonly bool[] _clientManaged; + private readonly bool[] _assigned; - private Switch _device; + private readonly Switch _device; private readonly object _syncpointAllocatorLock = new(); public NvHostSyncpt(Switch device) { - _device = device; - _counterMin = new int[SynchronizationManager.MaxHardwareSyncpoints]; - _counterMax = new int[SynchronizationManager.MaxHardwareSyncpoints]; + _device = device; + _counterMin = new int[SynchronizationManager.MaxHardwareSyncpoints]; + _counterMax = new int[SynchronizationManager.MaxHardwareSyncpoints]; _clientManaged = new bool[SynchronizationManager.MaxHardwareSyncpoints]; - _assigned = new bool[SynchronizationManager.MaxHardwareSyncpoints]; + _assigned = new bool[SynchronizationManager.MaxHardwareSyncpoints]; // Reserve VBLANK syncpoints ReserveSyncpointLocked(VBlank0SyncpointId, true); @@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl throw new ArgumentOutOfRangeException(nameof(id)); } - _assigned[id] = true; + _assigned[id] = true; _clientManaged[id] = isClientManaged; } @@ -76,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl throw new ArgumentOutOfRangeException(nameof(id)); } - _assigned[id] = false; + _assigned[id] = false; _clientManaged[id] = false; SetSyncpointMinEqualSyncpointMax(id); @@ -196,4 +196,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl } } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs index cda97f18..b0efb7ed 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitArguments.cs @@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types struct SyncptWaitArguments { public NvFence Fence; - public int Timeout; + public int Timeout; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs index f2279c3d..7471274b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/SyncptWaitExArguments.cs @@ -6,6 +6,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types struct SyncptWaitExArguments { public SyncptWaitArguments Input; - public uint Value; + public uint Value; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs index d6a8e29f..23cf1f00 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/NvHostCtrlGpuDeviceFile.cs @@ -10,15 +10,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu { class NvHostCtrlGpuDeviceFile : NvDeviceFile { - private static Stopwatch _pTimer = new Stopwatch(); - private static double _ticksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000; + private static readonly Stopwatch _pTimer = new(); + private static readonly double _ticksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000; - private KEvent _errorEvent; - private KEvent _unknownEvent; + private readonly KEvent _errorEvent; + private readonly KEvent _unknownEvent; public NvHostCtrlGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { - _errorEvent = new KEvent(context.Device.System.KernelContext); + _errorEvent = new KEvent(context.Device.System.KernelContext); _unknownEvent = new KEvent(context.Device.System.KernelContext); } @@ -125,6 +125,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu private NvInternalResult ZcullGetInfo(ref ZcullGetInfoArguments arguments) { +#pragma warning disable IDE0055 // Disable formatting arguments.WidthAlignPixels = 0x20; arguments.HeightAlignPixels = 0x20; arguments.PixelSquaresByAliquots = 0x400; @@ -135,6 +136,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu arguments.SubregionWidthAlignPixels = 0x20; arguments.SubregionHeightAlignPixels = 0x40; arguments.SubregionCount = 0x10; +#pragma warning restore IDE0055 return NvInternalResult.Success; } @@ -155,6 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu { arguments.Header.BufferSize = 0xa0; +#pragma warning disable IDE0055 // Disable formatting characteristics.Arch = 0x120; characteristics.Impl = 0xb; characteristics.Rev = 0xa1; @@ -190,6 +193,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu characteristics.RopL2EnMask1 = 0x0; characteristics.ChipName = 0x6230326d67; characteristics.GrCompbitStoreBaseHw = 0x0; +#pragma warning restore IDE0055 arguments.Characteristics = characteristics; @@ -205,7 +209,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu { if (arguments.MaskBufferSize != 0) { - tpcMask = 3; + tpcMask = 3; arguments.TpcMask = tpcMask; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs index d6648178..64bfbe88 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetCharacteristicsArguments.cs @@ -5,46 +5,46 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types [StructLayout(LayoutKind.Sequential)] struct GpuCharacteristics { - public int Arch; - public int Impl; - public int Rev; - public int NumGpc; + public int Arch; + public int Impl; + public int Rev; + public int NumGpc; public long L2CacheSize; public long OnBoardVideoMemorySize; - public int NumTpcPerGpc; - public int BusType; - public int BigPageSize; - public int CompressionPageSize; - public int PdeCoverageBitCount; - public int AvailableBigPageSizes; - public int GpcMask; - public int SmArchSmVersion; - public int SmArchSpaVersion; - public int SmArchWarpCount; - public int GpuVaBitCount; - public int Reserved; + public int NumTpcPerGpc; + public int BusType; + public int BigPageSize; + public int CompressionPageSize; + public int PdeCoverageBitCount; + public int AvailableBigPageSizes; + public int GpcMask; + public int SmArchSmVersion; + public int SmArchSpaVersion; + public int SmArchWarpCount; + public int GpuVaBitCount; + public int Reserved; public long Flags; - public int TwodClass; - public int ThreedClass; - public int ComputeClass; - public int GpfifoClass; - public int InlineToMemoryClass; - public int DmaCopyClass; - public int MaxFbpsCount; - public int FbpEnMask; - public int MaxLtcPerFbp; - public int MaxLtsPerLtc; - public int MaxTexPerTpc; - public int MaxGpcCount; - public int RopL2EnMask0; - public int RopL2EnMask1; + public int TwodClass; + public int ThreedClass; + public int ComputeClass; + public int GpfifoClass; + public int InlineToMemoryClass; + public int DmaCopyClass; + public int MaxFbpsCount; + public int FbpEnMask; + public int MaxLtcPerFbp; + public int MaxLtsPerLtc; + public int MaxTexPerTpc; + public int MaxGpcCount; + public int RopL2EnMask0; + public int RopL2EnMask1; public long ChipName; public long GrCompbitStoreBaseHw; } struct CharacteristicsHeader { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public long BufferSize; public long BufferAddress; #pragma warning restore CS0649 @@ -54,6 +54,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types struct GetCharacteristicsArguments { public CharacteristicsHeader Header; - public GpuCharacteristics Characteristics; + public GpuCharacteristics Characteristics; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs index 16ef2d6e..dafde6e5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/GetTpcMasksArguments.cs @@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types [StructLayout(LayoutKind.Sequential)] struct GetTpcMasksArguments { - public int MaskBufferSize; - public int Reserved; + public int MaskBufferSize; + public int Reserved; public long MaskBufferAddress; - public int TpcMask; - public int Padding; + public int TpcMask; + public int Padding; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs index a4651f84..93c26433 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrlGpu/Types/ZbcSetTableArguments.cs @@ -1,5 +1,4 @@ using Ryujinx.Common.Memory; -using System; using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs index fe302b98..66791578 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs @@ -1,5 +1,5 @@ using Ryujinx.Memory; -using System; + namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostDbgGpu { class NvHostDbgGpuDeviceFile : NvDeviceFile diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs index 9a3aa7aa..c7746a55 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvInternalResult.cs @@ -2,31 +2,31 @@ { enum NvInternalResult { - Success = 0, + Success = 0, OperationNotPermitted = -1, - NoEntry = -2, - Interrupted = -4, - IoError = -5, - DeviceNotFound = -6, - BadFileNumber = -9, - TryAgain = -11, - OutOfMemory = -12, - AccessDenied = -13, - BadAddress = -14, - Busy = -16, - NotADirectory = -20, - InvalidInput = -22, - FileTableOverflow = -23, - Unknown0x18 = -24, - NotSupported = -25, - FileTooBig = -27, - NoSpaceLeft = -28, - ReadOnlyAttribute = -30, - NotImplemented = -38, - InvalidState = -40, - Restart = -85, - InvalidAddress = -99, - TimedOut = -110, - Unknown0x72 = -114, + NoEntry = -2, + Interrupted = -4, + IoError = -5, + DeviceNotFound = -6, + BadFileNumber = -9, + TryAgain = -11, + OutOfMemory = -12, + AccessDenied = -13, + BadAddress = -14, + Busy = -16, + NotADirectory = -20, + InvalidInput = -22, + FileTableOverflow = -23, + Unknown0x18 = -24, + NotSupported = -25, + FileTooBig = -27, + NoSpaceLeft = -28, + ReadOnlyAttribute = -30, + NotImplemented = -38, + InvalidState = -40, + Restart = -85, + InvalidAddress = -99, + TimedOut = -110, + Unknown0x72 = -114, } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs index a52b36a2..06df5f93 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/NvMapDeviceFile.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { private const int FlagNotFreedYet = 1; - private static NvMapIdDictionary _maps = new NvMapIdDictionary(); + private static readonly NvMapIdDictionary _maps = new(); public NvMapDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { @@ -125,8 +125,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { map.Allocated = true; - map.Align = arguments.Align; - map.Kind = (byte)arguments.Kind; + map.Align = arguments.Align; + map.Kind = (byte)arguments.Kind; int size = BitUtils.AlignUp(map.Size, (int)MemoryManager.PageSize); @@ -142,7 +142,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap if (result == NvInternalResult.Success) { - map.Size = size; + map.Size = size; map.Address = address; } } @@ -164,12 +164,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap if (DecrementMapRefCount(Owner, arguments.Handle)) { arguments.Address = map.Address; - arguments.Flags = 0; + arguments.Flags = 0; } else { arguments.Address = 0; - arguments.Flags = FlagNotFreedYet; + arguments.Flags = FlagNotFreedYet; } arguments.Size = map.Size; @@ -190,15 +190,26 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap switch (arguments.Param) { - case NvMapHandleParam.Size: arguments.Result = map.Size; break; - case NvMapHandleParam.Align: arguments.Result = map.Align; break; - case NvMapHandleParam.Heap: arguments.Result = 0x40000000; break; - case NvMapHandleParam.Kind: arguments.Result = map.Kind; break; - case NvMapHandleParam.Compr: arguments.Result = 0; break; + case NvMapHandleParam.Size: + arguments.Result = map.Size; + break; + case NvMapHandleParam.Align: + arguments.Result = map.Align; + break; + case NvMapHandleParam.Heap: + arguments.Result = 0x40000000; + break; + case NvMapHandleParam.Kind: + arguments.Result = map.Kind; + break; + case NvMapHandleParam.Compr: + arguments.Result = 0; + break; // Note: Base is not supported and returns an error. // Any other value also returns an error. - default: return NvInternalResult.InvalidInput; + default: + return NvInternalResult.InvalidInput; } return NvInternalResult.Success; diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs index 2ec75fc9..dc4f5d60 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapAlloc.cs @@ -5,11 +5,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapAlloc { - public int Handle; - public int HeapMask; - public int Flags; - public int Align; - public long Kind; + public int Handle; + public int HeapMask; + public int Flags; + public int Align; + public long Kind; public ulong Address; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs index b47e4629..5380c45c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapCreate.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap public int Size; public int Handle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs index 34bcbc64..b0b3fa2d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFree.cs @@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapFree { - public int Handle; - public int Padding; + public int Handle; + public int Padding; public ulong Address; - public int Size; - public int Flags; + public int Size; + public int Flags; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs index 2e559534..9ec81f9f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapFromId.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap public int Id; public int Handle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs index fe574eea..8306ae4c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapGetId.cs @@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap public int Id; public int Handle; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs index c97cee49..30117974 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandle.cs @@ -4,15 +4,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { class NvMapHandle { -#pragma warning disable CS0649 - public int Handle; - public int Id; +#pragma warning disable CS0649 // Field is never assigned to + public int Handle; + public int Id; #pragma warning restore CS0649 - public int Size; - public int Align; - public int Kind; + public int Size; + public int Align; + public int Kind; public ulong Address; - public bool Allocated; + public bool Allocated; public ulong DmaMapAddress; private long _dupes; @@ -37,4 +37,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap return Interlocked.Decrement(ref _dupes); } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs index 9eb7efff..21393e7a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapHandleParam.cs @@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap { enum NvMapHandleParam { - Size = 1, + Size = 1, Align = 2, - Base = 3, - Heap = 4, - Kind = 5, - Compr = 6 + Base = 3, + Heap = 4, + Kind = 5, + Compr = 6, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs index c4733e94..1b4d8dd4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapIdDictionary.cs @@ -58,4 +58,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap return values; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs index de5bab77..16fd7804 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvMap/Types/NvMapParam.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap [StructLayout(LayoutKind.Sequential)] struct NvMapParam { - public int Handle; + public int Handle; public NvMapHandleParam Param; - public int Result; + public int Result; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs index 05858694..c9218e67 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs @@ -7,39 +7,39 @@ namespace Ryujinx.HLE.HOS.Services.Nv struct NvIoctl { public const int NvHostCustomMagic = 0x00; - public const int NvMapCustomMagic = 0x01; - public const int NvGpuAsMagic = 0x41; - public const int NvGpuMagic = 0x47; - public const int NvHostMagic = 0x48; + public const int NvMapCustomMagic = 0x01; + public const int NvGpuAsMagic = 0x41; + public const int NvGpuMagic = 0x47; + public const int NvHostMagic = 0x48; - private const int NumberBits = 8; - private const int TypeBits = 8; - private const int SizeBits = 14; + private const int NumberBits = 8; + private const int TypeBits = 8; + private const int SizeBits = 14; private const int DirectionBits = 2; - private const int NumberShift = 0; - private const int TypeShift = NumberShift + NumberBits; - private const int SizeShift = TypeShift + TypeBits; + private const int NumberShift = 0; + private const int TypeShift = NumberShift + NumberBits; + private const int SizeShift = TypeShift + TypeBits; private const int DirectionShift = SizeShift + SizeBits; - private const int NumberMask = (1 << NumberBits) - 1; - private const int TypeMask = (1 << TypeBits) - 1; - private const int SizeMask = (1 << SizeBits) - 1; + private const int NumberMask = (1 << NumberBits) - 1; + private const int TypeMask = (1 << TypeBits) - 1; + private const int SizeMask = (1 << SizeBits) - 1; private const int DirectionMask = (1 << DirectionBits) - 1; [Flags] public enum Direction : uint { - None = 0, - Read = 1, + None = 0, + Read = 1, Write = 2, } public uint RawValue; - public uint Number => (RawValue >> NumberShift) & NumberMask; - public uint Type => (RawValue >> TypeShift) & TypeMask; - public uint Size => (RawValue >> SizeShift) & SizeMask; - public Direction DirectionValue => (Direction)((RawValue >> DirectionShift) & DirectionMask); + public readonly uint Number => (RawValue >> NumberShift) & NumberMask; + public readonly uint Type => (RawValue >> TypeShift) & TypeMask; + public readonly uint Size => (RawValue >> SizeShift) & SizeMask; + public readonly Direction DirectionValue => (Direction)((RawValue >> DirectionShift) & DirectionMask); } } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs index 341b5e57..66c953a2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs @@ -20,10 +20,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv // Key --> Start Address of Region // Value --> End Address of Region - private readonly TreeDictionary<ulong, ulong> _tree = new TreeDictionary<ulong, ulong>(); + private readonly TreeDictionary<ulong, ulong> _tree = new(); - private readonly Dictionary<ulong, LinkedListNode<ulong>> _dictionary = new Dictionary<ulong, LinkedListNode<ulong>>(); - private readonly LinkedList<ulong> _list = new LinkedList<ulong>(); + private readonly Dictionary<ulong, LinkedListNode<ulong>> _dictionary = new(); + private readonly LinkedList<ulong> _list = new(); public NvMemoryAllocator() { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs index 664610a4..5af613cd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvFence.cs @@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public uint Id; public uint Value; - public bool IsValid() + public readonly bool IsValid() { return Id != InvalidSyncPointId; } @@ -28,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types Value = gpuContext.Synchronization.IncrementSyncpoint(Id); } - public bool Wait(GpuContext gpuContext, TimeSpan timeout) + public readonly bool Wait(GpuContext gpuContext, TimeSpan timeout) { if (IsValid()) { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs index 9404c18c..7af7e533 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvIoctlNotImplementedException.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types { class NvIoctlNotImplementedException : Exception { - public ServiceCtx Context { get; } + public ServiceCtx Context { get; } public NvDeviceFile DeviceFile { get; } - public NvIoctl Command { get; } + public NvIoctl Command { get; } public NvIoctlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, NvIoctl command) : this(context, deviceFile, command, "The ioctl is not implemented.") @@ -17,9 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public NvIoctlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, NvIoctl command, string message) : base(message) { - Context = context; + Context = context; DeviceFile = deviceFile; - Command = command; + Command = command; } public override string Message @@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types private string BuildMessage() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.AppendLine($"Device File: {DeviceFile.GetType().Name}"); sb.AppendLine(); diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs index b7a72eba..844bce13 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvQueryEventNotImplementedException.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types { class NvQueryEventNotImplementedException : Exception { - public ServiceCtx Context { get; } + public ServiceCtx Context { get; } public NvDeviceFile DeviceFile { get; } - public uint EventId { get; } + public uint EventId { get; } public NvQueryEventNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId) : this(context, deviceFile, eventId, "This query event is not implemented.") @@ -17,9 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public NvQueryEventNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId, string message) : base(message) { - Context = context; + Context = context; DeviceFile = deviceFile; - EventId = eventId; + EventId = eventId; } public override string Message @@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types private string BuildMessage() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.AppendLine($"Device File: {DeviceFile.GetType().Name}"); sb.AppendLine(); diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs index 1c9cae8c..6f7e09a6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvResult.cs @@ -2,29 +2,29 @@ namespace Ryujinx.HLE.HOS.Services.Nv { enum NvResult : uint { - Success = 0, - NotImplemented = 1, - NotSupported = 2, - NotInitialized = 3, - InvalidParameter = 4, - Timeout = 5, - InsufficientMemory = 6, - ReadOnlyAttribute = 7, - InvalidState = 8, - InvalidAddress = 9, - InvalidSize = 10, - InvalidValue = 11, - AlreadyAllocated = 13, - Busy = 14, - ResourceError = 15, - CountMismatch = 16, - SharedMemoryTooSmall = 0x1000, - FileOperationFailed = 0x30003, + Success = 0, + NotImplemented = 1, + NotSupported = 2, + NotInitialized = 3, + InvalidParameter = 4, + Timeout = 5, + InsufficientMemory = 6, + ReadOnlyAttribute = 7, + InvalidState = 8, + InvalidAddress = 9, + InvalidSize = 10, + InvalidValue = 11, + AlreadyAllocated = 13, + Busy = 14, + ResourceError = 15, + CountMismatch = 16, + SharedMemoryTooSmall = 0x1000, + FileOperationFailed = 0x30003, DirectoryOperationFailed = 0x30004, NotAvailableInProduction = 0x30006, - IoctlFailed = 0x3000F, - AccessDenied = 0x30010, - FileNotFound = 0x30013, - ModuleNotPresent = 0xA000E, + IoctlFailed = 0x3000F, + AccessDenied = 0x30010, + FileNotFound = 0x30013, + ModuleNotPresent = 0xA000E, } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs index d5c35265..ad4f7035 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Types/NvStatus.cs @@ -12,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types public long Padding1; public long Padding2; } -}
\ No newline at end of file +} |
