2018-04-08 12:17:35 -07:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
|
2018-06-23 17:39:25 -07:00
|
|
|
namespace Ryujinx.HLE.Gpu.Memory
|
2018-04-08 12:17:35 -07:00
|
|
|
{
|
2018-06-08 17:15:56 -07:00
|
|
|
static class NvGpuPushBuffer
|
2018-04-08 12:17:35 -07:00
|
|
|
{
|
|
|
|
private enum SubmissionMode
|
|
|
|
{
|
|
|
|
Incrementing = 1,
|
|
|
|
NonIncrementing = 3,
|
|
|
|
Immediate = 4,
|
|
|
|
IncrementOnce = 5
|
|
|
|
}
|
|
|
|
|
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 11:53:23 -07:00
|
|
|
public static NvGpuPBEntry[] Decode(byte[] Data)
|
2018-04-08 12:17:35 -07:00
|
|
|
{
|
|
|
|
using (MemoryStream MS = new MemoryStream(Data))
|
|
|
|
{
|
|
|
|
BinaryReader Reader = new BinaryReader(MS);
|
|
|
|
|
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 11:53:23 -07:00
|
|
|
List<NvGpuPBEntry> PushBuffer = new List<NvGpuPBEntry>();
|
2018-04-08 12:17:35 -07:00
|
|
|
|
|
|
|
bool CanRead() => MS.Position + 4 <= MS.Length;
|
|
|
|
|
|
|
|
while (CanRead())
|
|
|
|
{
|
|
|
|
int Packed = Reader.ReadInt32();
|
|
|
|
|
|
|
|
int Meth = (Packed >> 0) & 0x1fff;
|
|
|
|
int SubC = (Packed >> 13) & 7;
|
|
|
|
int Args = (Packed >> 16) & 0x1fff;
|
|
|
|
int Mode = (Packed >> 29) & 7;
|
|
|
|
|
|
|
|
switch ((SubmissionMode)Mode)
|
|
|
|
{
|
|
|
|
case SubmissionMode.Incrementing:
|
|
|
|
{
|
|
|
|
for (int Index = 0; Index < Args && CanRead(); Index++, Meth++)
|
|
|
|
{
|
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 11:53:23 -07:00
|
|
|
PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Reader.ReadInt32()));
|
2018-04-08 12:17:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SubmissionMode.NonIncrementing:
|
|
|
|
{
|
|
|
|
int[] Arguments = new int[Args];
|
|
|
|
|
|
|
|
for (int Index = 0; Index < Arguments.Length; Index++)
|
|
|
|
{
|
|
|
|
if (!CanRead())
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Arguments[Index] = Reader.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 11:53:23 -07:00
|
|
|
PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Arguments));
|
2018-04-08 12:17:35 -07:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SubmissionMode.Immediate:
|
|
|
|
{
|
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 11:53:23 -07:00
|
|
|
PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Args));
|
2018-04-08 12:17:35 -07:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SubmissionMode.IncrementOnce:
|
|
|
|
{
|
|
|
|
if (CanRead())
|
|
|
|
{
|
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 11:53:23 -07:00
|
|
|
PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Reader.ReadInt32()));
|
2018-04-08 12:17:35 -07: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 11:53:23 -07:00
|
|
|
|
2018-04-08 12:17:35 -07:00
|
|
|
if (CanRead() && Args > 1)
|
|
|
|
{
|
|
|
|
int[] Arguments = new int[Args - 1];
|
|
|
|
|
|
|
|
for (int Index = 0; Index < Arguments.Length && CanRead(); Index++)
|
|
|
|
{
|
|
|
|
Arguments[Index] = Reader.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 11:53:23 -07:00
|
|
|
PushBuffer.Add(new NvGpuPBEntry(Meth + 1, SubC, Arguments));
|
2018-04-08 12:17:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PushBuffer.ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|