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 14:53:23 -04:00
|
|
|
using ChocolArm64.Memory;
|
2018-10-17 13:15:50 -04:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-09-08 13:51:50 -04:00
|
|
|
using Ryujinx.Graphics.Memory;
|
2018-11-28 17:18:09 -05:00
|
|
|
using Ryujinx.HLE.HOS.Kernel;
|
2018-08-16 19:47:36 -04:00
|
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS;
|
2018-12-02 21:38:47 -05:00
|
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvMap;
|
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 14:53:23 -04:00
|
|
|
using System;
|
2018-07-14 23:04:46 -04:00
|
|
|
using System.Collections.Concurrent;
|
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 14:53:23 -04:00
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel
|
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 14:53:23 -04:00
|
|
|
{
|
|
|
|
class NvHostChannelIoctl
|
|
|
|
{
|
2018-12-02 21:38:47 -05:00
|
|
|
private static ConcurrentDictionary<KProcess, NvChannel> Channels;
|
2018-07-14 23:04:46 -04:00
|
|
|
|
|
|
|
static NvHostChannelIoctl()
|
|
|
|
{
|
2018-12-02 21:38:47 -05:00
|
|
|
Channels = new ConcurrentDictionary<KProcess, NvChannel>();
|
2018-07-14 23:04:46 -04:00
|
|
|
}
|
|
|
|
|
2018-12-02 21:38:47 -05:00
|
|
|
public static int ProcessIoctl(ServiceCtx Context, int Cmd)
|
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 14:53:23 -04:00
|
|
|
{
|
|
|
|
switch (Cmd & 0xffff)
|
|
|
|
{
|
2018-12-02 21:38:47 -05:00
|
|
|
case 0x0001: return Submit (Context);
|
|
|
|
case 0x0002: return GetSyncpoint (Context);
|
|
|
|
case 0x0003: return GetWaitBase (Context);
|
|
|
|
case 0x0009: return MapBuffer (Context);
|
|
|
|
case 0x000a: return UnmapBuffer (Context);
|
2018-07-14 23:04:46 -04:00
|
|
|
case 0x4714: return SetUserData (Context);
|
|
|
|
case 0x4801: return SetNvMap (Context);
|
2018-12-02 21:38:47 -05:00
|
|
|
case 0x4803: return SetTimeout (Context);
|
2018-07-14 23:04:46 -04:00
|
|
|
case 0x4808: return SubmitGpfifo (Context);
|
|
|
|
case 0x4809: return AllocObjCtx (Context);
|
|
|
|
case 0x480b: return ZcullBind (Context);
|
|
|
|
case 0x480c: return SetErrorNotifier (Context);
|
|
|
|
case 0x480d: return SetPriority (Context);
|
|
|
|
case 0x481a: return AllocGpfifoEx2 (Context);
|
|
|
|
case 0x481b: return KickoffPbWithAttr(Context);
|
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 14:53:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new NotImplementedException(Cmd.ToString("x8"));
|
|
|
|
}
|
|
|
|
|
2018-12-02 21:38:47 -05:00
|
|
|
private static int Submit(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
|
|
|
|
|
|
|
NvHostChannelSubmit Args = MemoryHelper.Read<NvHostChannelSubmit>(Context.Memory, InputPosition);
|
|
|
|
|
|
|
|
NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
|
|
|
|
|
|
|
|
for (int Index = 0; Index < Args.CmdBufsCount; Index++)
|
|
|
|
{
|
|
|
|
long CmdBufOffset = InputPosition + 0x10 + Index * 0xc;
|
|
|
|
|
|
|
|
NvHostChannelCmdBuf CmdBuf = MemoryHelper.Read<NvHostChannelCmdBuf>(Context.Memory, CmdBufOffset);
|
|
|
|
|
|
|
|
NvMapHandle Map = NvMapIoctl.GetNvMap(Context, CmdBuf.MemoryId);
|
|
|
|
|
|
|
|
int[] CmdBufData = new int[CmdBuf.WordsCount];
|
|
|
|
|
|
|
|
for (int Offset = 0; Offset < CmdBufData.Length; Offset++)
|
|
|
|
{
|
|
|
|
CmdBufData[Offset] = Context.Memory.ReadInt32(Map.Address + CmdBuf.Offset + Offset * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
Context.Device.Gpu.PushCommandBuffer(Vmm, CmdBufData);
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: Relocation, waitchecks, etc.
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int GetSyncpoint(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
//TODO
|
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
|
|
|
|
|
|
|
NvHostChannelGetParamArg Args = MemoryHelper.Read<NvHostChannelGetParamArg>(Context.Memory, InputPosition);
|
|
|
|
|
|
|
|
Args.Value = 0;
|
|
|
|
|
|
|
|
MemoryHelper.Write(Context.Memory, OutputPosition, Args);
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int GetWaitBase(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
|
|
|
|
|
|
|
NvHostChannelGetParamArg Args = MemoryHelper.Read<NvHostChannelGetParamArg>(Context.Memory, InputPosition);
|
|
|
|
|
|
|
|
Args.Value = 0;
|
|
|
|
|
|
|
|
MemoryHelper.Write(Context.Memory, OutputPosition, Args);
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int MapBuffer(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
|
|
|
|
|
|
|
NvHostChannelMapBuffer Args = MemoryHelper.Read<NvHostChannelMapBuffer>(Context.Memory, InputPosition);
|
|
|
|
|
|
|
|
NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
|
|
|
|
|
|
|
|
for (int Index = 0; Index < Args.NumEntries; Index++)
|
|
|
|
{
|
|
|
|
int Handle = Context.Memory.ReadInt32(InputPosition + 0xc + Index * 8);
|
|
|
|
|
|
|
|
NvMapHandle Map = NvMapIoctl.GetNvMap(Context, Handle);
|
|
|
|
|
|
|
|
if (Map == null)
|
|
|
|
{
|
|
|
|
Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Handle:x8}!");
|
|
|
|
|
|
|
|
return NvResult.InvalidInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
lock (Map)
|
|
|
|
{
|
|
|
|
if (Map.DmaMapAddress == 0)
|
|
|
|
{
|
|
|
|
Map.DmaMapAddress = Vmm.MapLow(Map.Address, Map.Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
Context.Memory.WriteInt32(OutputPosition + 0xc + 4 + Index * 8, (int)Map.DmaMapAddress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int UnmapBuffer(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
|
|
|
|
NvHostChannelMapBuffer Args = MemoryHelper.Read<NvHostChannelMapBuffer>(Context.Memory, InputPosition);
|
|
|
|
|
|
|
|
NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
|
|
|
|
|
|
|
|
for (int Index = 0; Index < Args.NumEntries; Index++)
|
|
|
|
{
|
|
|
|
int Handle = Context.Memory.ReadInt32(InputPosition + 0xc + Index * 8);
|
|
|
|
|
|
|
|
NvMapHandle Map = NvMapIoctl.GetNvMap(Context, Handle);
|
|
|
|
|
|
|
|
if (Map == null)
|
|
|
|
{
|
|
|
|
Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Handle:x8}!");
|
|
|
|
|
|
|
|
return NvResult.InvalidInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
lock (Map)
|
|
|
|
{
|
|
|
|
if (Map.DmaMapAddress != 0)
|
|
|
|
{
|
|
|
|
Vmm.Free(Map.DmaMapAddress, Map.Size);
|
|
|
|
|
|
|
|
Map.DmaMapAddress = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
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 14:53:23 -04:00
|
|
|
private static int SetUserData(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int SetNvMap(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-02 21:38:47 -05:00
|
|
|
private static int SetTimeout(ServiceCtx Context)
|
2018-07-14 23:04:46 -04:00
|
|
|
{
|
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
|
2018-12-02 21:38:47 -05:00
|
|
|
GetChannel(Context).Timeout = Context.Memory.ReadInt32(InputPosition);
|
2018-07-14 23:04:46 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
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 14:53:23 -04:00
|
|
|
private static int SubmitGpfifo(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
NvHostChannelSubmitGpfifo Args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition);
|
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 14:53:23 -04:00
|
|
|
|
2018-08-15 14:59:51 -04:00
|
|
|
NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;;
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
for (int Index = 0; Index < Args.NumEntries; Index++)
|
|
|
|
{
|
|
|
|
long Gpfifo = Context.Memory.ReadInt64(InputPosition + 0x18 + Index * 8);
|
|
|
|
|
2018-07-14 23:04:46 -04:00
|
|
|
PushGpfifo(Context, Vmm, Gpfifo);
|
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 14:53:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Args.SyncptId = 0;
|
|
|
|
Args.SyncptValue = 0;
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
MemoryHelper.Write(Context.Memory, OutputPosition, Args);
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int AllocObjCtx(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int ZcullBind(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int SetErrorNotifier(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int SetPriority(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int AllocGpfifoEx2(ServiceCtx Context)
|
|
|
|
{
|
2018-06-02 18:46:09 -04:00
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
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 14:53:23 -04:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
|
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 14:53:23 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
2018-07-14 23:04:46 -04:00
|
|
|
|
|
|
|
private static int KickoffPbWithAttr(ServiceCtx Context)
|
|
|
|
{
|
|
|
|
long InputPosition = Context.Request.GetBufferType0x21().Position;
|
|
|
|
long OutputPosition = Context.Request.GetBufferType0x22().Position;
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
NvHostChannelSubmitGpfifo Args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition);
|
2018-07-14 23:04:46 -04:00
|
|
|
|
2018-08-15 14:59:51 -04:00
|
|
|
NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;;
|
2018-07-14 23:04:46 -04:00
|
|
|
|
|
|
|
for (int Index = 0; Index < Args.NumEntries; Index++)
|
|
|
|
{
|
|
|
|
long Gpfifo = Context.Memory.ReadInt64(Args.Address + Index * 8);
|
|
|
|
|
|
|
|
PushGpfifo(Context, Vmm, Gpfifo);
|
|
|
|
}
|
|
|
|
|
|
|
|
Args.SyncptId = 0;
|
|
|
|
Args.SyncptValue = 0;
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
MemoryHelper.Write(Context.Memory, OutputPosition, Args);
|
2018-07-14 23:04:46 -04:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void PushGpfifo(ServiceCtx Context, NvGpuVmm Vmm, long Gpfifo)
|
|
|
|
{
|
2018-11-16 23:01:31 -05:00
|
|
|
Context.Device.Gpu.Pusher.Push(Vmm, Gpfifo);
|
2018-07-14 23:04:46 -04:00
|
|
|
}
|
|
|
|
|
2018-12-02 21:38:47 -05:00
|
|
|
public static NvChannel GetChannel(ServiceCtx Context)
|
2018-07-14 23:04:46 -04:00
|
|
|
{
|
2018-12-02 21:38:47 -05:00
|
|
|
return Channels.GetOrAdd(Context.Process, (Key) => new NvChannel());
|
2018-07-14 23:04:46 -04:00
|
|
|
}
|
|
|
|
|
2018-11-28 17:18:09 -05:00
|
|
|
public static void UnloadProcess(KProcess Process)
|
2018-07-14 23:04:46 -04:00
|
|
|
{
|
|
|
|
Channels.TryRemove(Process, out _);
|
|
|
|
}
|
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 14:53:23 -04:00
|
|
|
}
|
|
|
|
}
|