Merge shader branch, adding support for GLSL decompilation, a macro

interpreter, and a rewrite of the GPU code.
This commit is contained in:
gdkchan 2018-04-08 16:17:35 -03:00
parent 7acd0e0122
commit b9aa3966c0
77 changed files with 5301 additions and 766 deletions

View file

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
namespace Ryujinx.Graphics.Gpu
{
public struct NsGpuPBEntry
{
public NsGpuRegister Register { get; private set; }
public int Method { get; private set; }
public int SubChannel { get; private set; }
@ -15,65 +13,11 @@ namespace Ryujinx.Graphics.Gpu
public ReadOnlyCollection<int> Arguments => Array.AsReadOnly(m_Arguments);
public NsGpuPBEntry(NsGpuRegister Register, int SubChannel, params int[] Arguments)
public NsGpuPBEntry(int Method, int SubChannel, params int[] Arguments)
{
this.Register = Register;
this.Method = Method;
this.SubChannel = SubChannel;
this.m_Arguments = Arguments;
}
public static NsGpuPBEntry[] DecodePushBuffer(byte[] Data)
{
using (MemoryStream MS = new MemoryStream(Data))
{
BinaryReader Reader = new BinaryReader(MS);
List<NsGpuPBEntry> GpFifos = new List<NsGpuPBEntry>();
bool CanRead() => MS.Position + 4 <= MS.Length;
while (CanRead())
{
int Packed = Reader.ReadInt32();
int Reg = (Packed << 2) & 0x7ffc;
int SubC = (Packed >> 13) & 7;
int Args = (Packed >> 16) & 0x1fff;
int Mode = (Packed >> 29) & 7;
if (Mode == 4)
{
//Inline Mode.
GpFifos.Add(new NsGpuPBEntry((NsGpuRegister)Reg, SubC, Args));
}
else
{
//Word mode.
if (Mode == 1)
{
//Sequential Mode.
for (int Index = 0; Index < Args && CanRead(); Index++, Reg += 4)
{
GpFifos.Add(new NsGpuPBEntry((NsGpuRegister)Reg, SubC, Reader.ReadInt32()));
}
}
else
{
//Non-Sequential Mode.
int[] Arguments = new int[Args];
for (int Index = 0; Index < Args && CanRead(); Index++)
{
Arguments[Index] = Reader.ReadInt32();
}
GpFifos.Add(new NsGpuPBEntry((NsGpuRegister)Reg, SubC, Arguments));
}
}
}
return GpFifos.ToArray();
}
}
}
}