2018-02-05 00:08:20 +01:00
|
|
|
using ChocolArm64.Memory;
|
2018-04-24 20:57:39 +02:00
|
|
|
using Ryujinx.Core.Logging;
|
2018-03-19 19:58:46 +01:00
|
|
|
using Ryujinx.Core.OsHle.Handles;
|
2018-02-20 21:09:23 +01:00
|
|
|
using Ryujinx.Core.OsHle.Ipc;
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
using Ryujinx.Core.OsHle.Services.Nv.NvGpuAS;
|
|
|
|
using Ryujinx.Core.OsHle.Services.Nv.NvGpuGpu;
|
|
|
|
using Ryujinx.Core.OsHle.Services.Nv.NvHostChannel;
|
|
|
|
using Ryujinx.Core.OsHle.Services.Nv.NvHostCtrl;
|
|
|
|
using Ryujinx.Core.OsHle.Services.Nv.NvMap;
|
2018-02-05 00:08:20 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2018-03-20 21:00:00 +01:00
|
|
|
namespace Ryujinx.Core.OsHle.Services.Nv
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-04-06 06:01:52 +02:00
|
|
|
class INvDrvServices : IpcService, IDisposable
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private delegate int IoctlProcessor(ServiceCtx Context, int Cmd);
|
2018-02-05 00:08:20 +01:00
|
|
|
|
2018-02-25 05:34:16 +01:00
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-02-25 05:34:16 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static Dictionary<string, IoctlProcessor> IoctlProcessors =
|
|
|
|
new Dictionary<string, IoctlProcessor>()
|
|
|
|
{
|
|
|
|
{ "/dev/nvhost-as-gpu", ProcessIoctlNvGpuAS },
|
|
|
|
{ "/dev/nvhost-ctrl", ProcessIoctlNvHostCtrl },
|
|
|
|
{ "/dev/nvhost-ctrl-gpu", ProcessIoctlNvGpuGpu },
|
|
|
|
{ "/dev/nvhost-gpu", ProcessIoctlNvHostChannel },
|
|
|
|
{ "/dev/nvmap", ProcessIoctlNvMap }
|
|
|
|
};
|
2018-03-12 05:04:52 +01:00
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
public static GlobalStateTable Fds { get; private set; }
|
2018-03-12 05:04:52 +01:00
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
private KEvent Event;
|
2018-03-12 05:04:52 +01:00
|
|
|
|
2018-04-06 06:01:52 +02:00
|
|
|
public INvDrvServices()
|
2018-02-25 05:34:16 +01:00
|
|
|
{
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
{
|
2018-05-25 23:33:09 +02:00
|
|
|
{ 0, Open },
|
|
|
|
{ 1, Ioctl },
|
|
|
|
{ 2, Close },
|
|
|
|
{ 3, Initialize },
|
|
|
|
{ 4, QueryEvent },
|
|
|
|
{ 8, SetClientPid },
|
|
|
|
{ 13, FinishInitialize }
|
2018-03-12 05:04:52 +01:00
|
|
|
};
|
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
Event = new KEvent();
|
|
|
|
}
|
2018-03-12 05:04:52 +01:00
|
|
|
|
2018-04-06 06:01:52 +02:00
|
|
|
static INvDrvServices()
|
2018-03-19 19:58:46 +01:00
|
|
|
{
|
|
|
|
Fds = new GlobalStateTable();
|
2018-02-25 05:34:16 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public long Open(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
|
|
|
long NamePtr = Context.Request.SendBuff[0].Position;
|
|
|
|
|
|
|
|
string Name = AMemoryHelper.ReadAsciiString(Context.Memory, NamePtr);
|
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
int Fd = Fds.Add(Context.Process, new NvFd(Name));
|
2018-02-05 00:08:20 +01:00
|
|
|
|
|
|
|
Context.ResponseData.Write(Fd);
|
|
|
|
Context.ResponseData.Write(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public long Ioctl(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
|
|
|
int Fd = Context.RequestData.ReadInt32();
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
int Cmd = Context.RequestData.ReadInt32();
|
2018-04-05 02:01:36 +02:00
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
NvFd FdData = Fds.GetData<NvFd>(Context.Process, Fd);
|
2018-02-05 00:08:20 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
int Result;
|
2018-02-05 00:08:20 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
if (IoctlProcessors.TryGetValue(FdData.Name, out IoctlProcessor Process))
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
Result = Process(Context, Cmd);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new NotImplementedException($"{FdData.Name} {Cmd:x4}");
|
|
|
|
}
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
|
|
|
|
//TODO: Verify if the error codes needs to be translated.
|
|
|
|
Context.ResponseData.Write(Result);
|
|
|
|
|
|
|
|
return 0;
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public long Close(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
|
|
|
int Fd = Context.RequestData.ReadInt32();
|
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
Fds.Delete(Context.Process, Fd);
|
2018-02-05 00:08:20 +01:00
|
|
|
|
|
|
|
Context.ResponseData.Write(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public long Initialize(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
|
|
|
long TransferMemSize = Context.RequestData.ReadInt64();
|
|
|
|
int TransferMemHandle = Context.Request.HandleDesc.ToCopy[0];
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
NvMapIoctl.InitializeNvMap(Context);
|
2018-02-05 00:08:20 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
Context.ResponseData.Write(0);
|
2018-03-20 16:18:25 +01:00
|
|
|
|
2018-02-05 00:08:20 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public long QueryEvent(ServiceCtx Context)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
|
|
|
int Fd = Context.RequestData.ReadInt32();
|
|
|
|
int EventId = Context.RequestData.ReadInt32();
|
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
//TODO: Use Fd/EventId, different channels have different events.
|
|
|
|
int Handle = Context.Process.HandleTable.OpenHandle(Event);
|
|
|
|
|
|
|
|
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
|
2018-02-05 00:08:20 +01:00
|
|
|
|
|
|
|
Context.ResponseData.Write(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public long SetClientPid(ServiceCtx Context)
|
2018-02-07 00:28:32 +01:00
|
|
|
{
|
|
|
|
long Pid = Context.RequestData.ReadInt64();
|
|
|
|
|
|
|
|
Context.ResponseData.Write(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-06-03 01:40:26 +02:00
|
|
|
|
2018-05-25 23:33:09 +02:00
|
|
|
public long FinishInitialize(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
Context.Ns.Log.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-07 00:28:32 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static int ProcessIoctlNvGpuAS(ServiceCtx Context, int Cmd)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return ProcessIoctl(Context, Cmd, NvGpuASIoctl.ProcessIoctl);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static int ProcessIoctlNvHostCtrl(ServiceCtx Context, int Cmd)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return ProcessIoctl(Context, Cmd, NvHostCtrlIoctl.ProcessIoctl);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static int ProcessIoctlNvGpuGpu(ServiceCtx Context, int Cmd)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return ProcessIoctl(Context, Cmd, NvGpuGpuIoctl.ProcessIoctl);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static int ProcessIoctlNvHostChannel(ServiceCtx Context, int Cmd)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return ProcessIoctl(Context, Cmd, NvHostChannelIoctl.ProcessIoctl);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static int ProcessIoctlNvMap(ServiceCtx Context, int Cmd)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return ProcessIoctl(Context, Cmd, NvMapIoctl.ProcessIoctl);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static int ProcessIoctl(ServiceCtx Context, int Cmd, IoctlProcessor Processor)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-06-03 00:46:09 +02:00
|
|
|
if (CmdIn(Cmd) && Context.Request.GetBufferType0x21().Position == 0)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
Context.Ns.Log.PrintError(LogClass.ServiceNv, "Input buffer is null!");
|
2018-04-05 02:01:36 +02:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return NvResult.InvalidInput;
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
2018-06-03 00:46:09 +02:00
|
|
|
if (CmdOut(Cmd) && Context.Request.GetBufferType0x22().Position == 0)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
Context.Ns.Log.PrintError(LogClass.ServiceNv, "Output buffer is null!");
|
2018-04-05 02:01:36 +02:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return NvResult.InvalidInput;
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return Processor(Context, Cmd);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static bool CmdIn(int Cmd)
|
2018-03-06 21:27:50 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return ((Cmd >> 30) & 1) != 0;
|
2018-03-06 21:27:50 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
private static bool CmdOut(int Cmd)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
return ((Cmd >> 31) & 1) != 0;
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
public static void UnloadProcess(Process Process)
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
Fds.DeleteProcess(Process);
|
2018-03-12 05:04:52 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
NvGpuASIoctl.UnloadProcess(Process);
|
2018-02-05 00:08:20 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
NvHostCtrlIoctl.UnloadProcess(Process);
|
2018-02-05 00:08:20 +01:00
|
|
|
|
NvServices refactoring (#120)
* Initial implementation of NvMap/NvHostCtrl
* More work on NvHostCtrl
* Refactoring of nvservices, move GPU Vmm, make Vmm per-process, refactor most gpu devices, move Gpu to Core, fix CbBind
* Implement GetGpuTime, support CancelSynchronization, fix issue on InsertWaitingMutex, proper double buffering support (again, not working properly for commercial games, only hb)
* Try to fix perf regression reading/writing textures, moved syncpts and events to a UserCtx class, delete global state when the process exits, other minor tweaks
* Remove now unused code, add comment about probably wrong result codes
2018-05-07 20:53:23 +02:00
|
|
|
NvMapIoctl.UnloadProcess(Process);
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
2018-03-12 05:04:52 +01:00
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
public void Dispose()
|
2018-03-12 05:04:52 +01:00
|
|
|
{
|
2018-03-19 19:58:46 +01:00
|
|
|
Dispose(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool Disposing)
|
|
|
|
{
|
|
|
|
if (Disposing)
|
|
|
|
{
|
|
|
|
Event.Dispose();
|
|
|
|
}
|
2018-03-12 05:04:52 +01:00
|
|
|
}
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
2018-05-25 23:33:09 +02:00
|
|
|
}
|