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 ChocolArm64.Memory;
|
2018-10-17 19:15:50 +02:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-09-08 19:51:50 +02:00
|
|
|
using Ryujinx.Graphics.Memory;
|
2018-12-18 06:33:36 +01:00
|
|
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
2018-08-17 01:47:36 +02:00
|
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS;
|
2018-12-03 03:38:47 +01: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 20:53:23 +02:00
|
|
|
using System;
|
2018-07-15 05:04:46 +02: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 20:53:23 +02:00
|
|
|
|
2018-08-17 01:47:36 +02: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 20:53:23 +02:00
|
|
|
{
|
|
|
|
class NvHostChannelIoctl
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
private static ConcurrentDictionary<KProcess, NvChannel> _channels;
|
2018-07-15 05:04:46 +02:00
|
|
|
|
|
|
|
static NvHostChannelIoctl()
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
_channels = new ConcurrentDictionary<KProcess, NvChannel>();
|
2018-07-15 05:04:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
switch (cmd & 0xffff)
|
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
|
|
|
{
|
2018-12-06 12:16:24 +01: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);
|
|
|
|
case 0x4714: return SetUserData (context);
|
|
|
|
case 0x4801: return SetNvMap (context);
|
|
|
|
case 0x4803: return SetTimeout (context);
|
|
|
|
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 20:53:23 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
throw new NotImplementedException(cmd.ToString("x8"));
|
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
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int Submit(ServiceCtx context)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long inputPosition = context.Request.GetBufferType0x21().Position;
|
|
|
|
long outputPosition = context.Request.GetBufferType0x22().Position;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvHostChannelSubmit args = MemoryHelper.Read<NvHostChannelSubmit>(context.Memory, inputPosition);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
for (int index = 0; index < args.CmdBufsCount; index++)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long cmdBufOffset = inputPosition + 0x10 + index * 0xc;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvHostChannelCmdBuf cmdBuf = MemoryHelper.Read<NvHostChannelCmdBuf>(context.Memory, cmdBufOffset);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvMapHandle map = NvMapIoctl.GetNvMap(context, cmdBuf.MemoryId);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
int[] cmdBufData = new int[cmdBuf.WordsCount];
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
for (int offset = 0; offset < cmdBufData.Length; offset++)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
cmdBufData[offset] = context.Memory.ReadInt32(map.Address + cmdBuf.Offset + offset * 4);
|
2018-12-03 03:38:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
context.Device.Gpu.PushCommandBuffer(vmm, cmdBufData);
|
2018-12-03 03:38:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: Relocation, waitchecks, etc.
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int GetSyncpoint(ServiceCtx context)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
|
|
|
//TODO
|
2018-12-06 12:16:24 +01:00
|
|
|
long inputPosition = context.Request.GetBufferType0x21().Position;
|
|
|
|
long outputPosition = context.Request.GetBufferType0x22().Position;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvHostChannelGetParamArg args = MemoryHelper.Read<NvHostChannelGetParamArg>(context.Memory, inputPosition);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
args.Value = 0;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
MemoryHelper.Write(context.Memory, outputPosition, args);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int GetWaitBase(ServiceCtx context)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long inputPosition = context.Request.GetBufferType0x21().Position;
|
|
|
|
long outputPosition = context.Request.GetBufferType0x22().Position;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvHostChannelGetParamArg args = MemoryHelper.Read<NvHostChannelGetParamArg>(context.Memory, inputPosition);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
args.Value = 0;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
MemoryHelper.Write(context.Memory, outputPosition, args);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int MapBuffer(ServiceCtx context)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long inputPosition = context.Request.GetBufferType0x21().Position;
|
|
|
|
long outputPosition = context.Request.GetBufferType0x22().Position;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvHostChannelMapBuffer args = MemoryHelper.Read<NvHostChannelMapBuffer>(context.Memory, inputPosition);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
for (int index = 0; index < args.NumEntries; index++)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
int handle = context.Memory.ReadInt32(inputPosition + 0xc + index * 8);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvMapHandle map = NvMapIoctl.GetNvMap(context, handle);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (map == null)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{handle:x8}!");
|
2018-12-03 03:38:47 +01:00
|
|
|
|
|
|
|
return NvResult.InvalidInput;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
lock (map)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
if (map.DmaMapAddress == 0)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
map.DmaMapAddress = vmm.MapLow(map.Address, map.Size);
|
2018-12-03 03:38:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
context.Memory.WriteInt32(outputPosition + 0xc + 4 + index * 8, (int)map.DmaMapAddress);
|
2018-12-03 03:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int UnmapBuffer(ServiceCtx context)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long inputPosition = context.Request.GetBufferType0x21().Position;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvHostChannelMapBuffer args = MemoryHelper.Read<NvHostChannelMapBuffer>(context.Memory, inputPosition);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
for (int index = 0; index < args.NumEntries; index++)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
int handle = context.Memory.ReadInt32(inputPosition + 0xc + index * 8);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvMapHandle map = NvMapIoctl.GetNvMap(context, handle);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
if (map == null)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{handle:x8}!");
|
2018-12-03 03:38:47 +01:00
|
|
|
|
|
|
|
return NvResult.InvalidInput;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
lock (map)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
if (map.DmaMapAddress != 0)
|
2018-12-03 03:38:47 +01:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
vmm.Free(map.DmaMapAddress, map.Size);
|
2018-12-03 03:38:47 +01:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
map.DmaMapAddress = 0;
|
2018-12-03 03:38:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int SetUserData(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-10-17 19:15:50 +02: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int SetNvMap(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-10-17 19:15:50 +02: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int SetTimeout(ServiceCtx context)
|
2018-07-15 05:04:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long inputPosition = context.Request.GetBufferType0x21().Position;
|
2018-07-15 05:04:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
GetChannel(context).Timeout = context.Memory.ReadInt32(inputPosition);
|
2018-07-15 05:04:46 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int SubmitGpfifo(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
for (int index = 0; index < args.NumEntries; index++)
|
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
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long gpfifo = context.Memory.ReadInt64(inputPosition + 0x18 + index * 8);
|
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
|
|
|
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
args.SyncptId = 0;
|
|
|
|
args.SyncptValue = 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
|
|
|
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int AllocObjCtx(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-10-17 19:15:50 +02: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int ZcullBind(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-10-17 19:15:50 +02: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int SetErrorNotifier(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-10-17 19:15:50 +02: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int SetPriority(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-10-17 19:15:50 +02: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int AllocGpfifoEx2(ServiceCtx 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 20:53:23 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01: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 20:53:23 +02:00
|
|
|
|
2018-10-17 19:15:50 +02: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 20:53:23 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
2018-07-15 05:04:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static int KickoffPbWithAttr(ServiceCtx context)
|
2018-07-15 05:04:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long inputPosition = context.Request.GetBufferType0x21().Position;
|
|
|
|
long outputPosition = context.Request.GetBufferType0x22().Position;
|
2018-07-15 05:04:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvHostChannelSubmitGpfifo args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(context.Memory, inputPosition);
|
2018-07-15 05:04:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
|
2018-07-15 05:04:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
for (int index = 0; index < args.NumEntries; index++)
|
2018-07-15 05:04:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
long gpfifo = context.Memory.ReadInt64(args.Address + index * 8);
|
2018-07-15 05:04:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
PushGpfifo(context, vmm, gpfifo);
|
2018-07-15 05:04:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
args.SyncptId = 0;
|
|
|
|
args.SyncptValue = 0;
|
2018-07-15 05:04:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
MemoryHelper.Write(context.Memory, outputPosition, args);
|
2018-07-15 05:04:46 +02:00
|
|
|
|
|
|
|
return NvResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
private static void PushGpfifo(ServiceCtx context, NvGpuVmm vmm, long gpfifo)
|
2018-07-15 05:04:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
context.Device.Gpu.Pusher.Push(vmm, gpfifo);
|
2018-07-15 05:04:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
public static NvChannel GetChannel(ServiceCtx context)
|
2018-07-15 05:04:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
return _channels.GetOrAdd(context.Process, (key) => new NvChannel());
|
2018-07-15 05:04:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
public static void UnloadProcess(KProcess process)
|
2018-07-15 05:04:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
_channels.TryRemove(process, out _);
|
2018-07-15 05:04:46 +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
|
|
|
}
|
|
|
|
}
|