[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,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
{
|
||||
public INvDrvDebugFSServices(ServiceCtx context) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
{
|
||||
public INvGemControl(ServiceCtx context) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
{
|
||||
public INvGemCoreDump(ServiceCtx context) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
[Flags]
|
||||
enum AddressSpaceFlags : uint
|
||||
{
|
||||
FixedOffset = 1,
|
||||
FixedOffset = 1,
|
||||
RemapSubRange = 0x100,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -1358,4 +1358,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
channel.Write(ClassId.Twod, 0x24C, 0x100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
{
|
||||
enum NvChannelPriority : uint
|
||||
{
|
||||
Low = 50,
|
||||
Low = 50,
|
||||
Medium = 100,
|
||||
High = 150
|
||||
High = 150,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types
|
|||
struct SyncptWaitArguments
|
||||
{
|
||||
public NvFence Fence;
|
||||
public int Timeout;
|
||||
public int Timeout;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types
|
|||
struct SyncptWaitExArguments
|
||||
{
|
||||
public SyncptWaitArguments Input;
|
||||
public uint Value;
|
||||
public uint Value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Ryujinx.Memory;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostDbgGpu
|
||||
{
|
||||
class NvHostDbgGpuDeviceFile : NvDeviceFile
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
public int Size;
|
||||
public int Handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
public int Id;
|
||||
public int Handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
public int Id;
|
||||
public int Handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,4 +58,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
return values;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,4 +12,4 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
|
|||
public long Padding1;
|
||||
public long Padding2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue