aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Memory/NvGpuPushBuffer.cs
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-09-08 14:51:50 -0300
committergdkchan <gab.dark.100@gmail.com>2018-09-08 14:51:50 -0300
commitce1d5be212e6f71a7ca32c3bd7b48e32d9f51b9a (patch)
tree759fe422127ce08c545d4616ccc9691f668032ec /Ryujinx.Graphics/Memory/NvGpuPushBuffer.cs
parenta0c78f792012cdea060444d7cb6a36dbabb04d52 (diff)
Move GPU emulation from Ryujinx.HLE to Ryujinx.Graphics and misc changes (#402)
* Move GPU LLE emulation from HLE to Graphics * Graphics: Move Gal/Texture to Texture * Remove Engines/ directory and namespace * Use tables for image formats * Abstract OpCode decoding * Simplify image table * Do not leak Read* symbols in TextureReader * Fixups * Rename IGalFrameBuffer -> IGalRenderTarget * Remove MaxBpp hardcoded value * Change yet again texture data and add G8R8 flipping * Rename GalFrameBufferFormat to GalSurfaceFormat * Unident EnsureSetup in ImageHandler * Add IsCompressed * Address some feedback
Diffstat (limited to 'Ryujinx.Graphics/Memory/NvGpuPushBuffer.cs')
-rw-r--r--Ryujinx.Graphics/Memory/NvGpuPushBuffer.cs101
1 files changed, 101 insertions, 0 deletions
diff --git a/Ryujinx.Graphics/Memory/NvGpuPushBuffer.cs b/Ryujinx.Graphics/Memory/NvGpuPushBuffer.cs
new file mode 100644
index 00000000..0902ebfc
--- /dev/null
+++ b/Ryujinx.Graphics/Memory/NvGpuPushBuffer.cs
@@ -0,0 +1,101 @@
+using System.Collections.Generic;
+using System.IO;
+
+namespace Ryujinx.Graphics.Memory
+{
+ public static class NvGpuPushBuffer
+ {
+ private enum SubmissionMode
+ {
+ Incrementing = 1,
+ NonIncrementing = 3,
+ Immediate = 4,
+ IncrementOnce = 5
+ }
+
+ public static NvGpuPBEntry[] Decode(byte[] Data)
+ {
+ using (MemoryStream MS = new MemoryStream(Data))
+ {
+ BinaryReader Reader = new BinaryReader(MS);
+
+ List<NvGpuPBEntry> PushBuffer = new List<NvGpuPBEntry>();
+
+ 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++)
+ {
+ PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Reader.ReadInt32()));
+ }
+
+ break;
+ }
+
+ case SubmissionMode.NonIncrementing:
+ {
+ int[] Arguments = new int[Args];
+
+ for (int Index = 0; Index < Arguments.Length; Index++)
+ {
+ if (!CanRead())
+ {
+ break;
+ }
+
+ Arguments[Index] = Reader.ReadInt32();
+ }
+
+ PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Arguments));
+
+ break;
+ }
+
+ case SubmissionMode.Immediate:
+ {
+ PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Args));
+
+ break;
+ }
+
+ case SubmissionMode.IncrementOnce:
+ {
+ if (CanRead())
+ {
+ PushBuffer.Add(new NvGpuPBEntry(Meth, SubC, Reader.ReadInt32()));
+ }
+
+ if (CanRead() && Args > 1)
+ {
+ int[] Arguments = new int[Args - 1];
+
+ for (int Index = 0; Index < Arguments.Length && CanRead(); Index++)
+ {
+ Arguments[Index] = Reader.ReadInt32();
+ }
+
+ PushBuffer.Add(new NvGpuPBEntry(Meth + 1, SubC, Arguments));
+ }
+
+ break;
+ }
+ }
+ }
+
+ return PushBuffer.ToArray();
+ }
+ }
+ }
+} \ No newline at end of file