From 1239c82d2f2fa59a42561a4a278a9cdca5eca462 Mon Sep 17 00:00:00 2001
From: riperiperi <rhy3756547@hotmail.com>
Date: Wed, 7 Apr 2021 13:19:02 +0100
Subject: Forcibly enable threaded optimization on boot.

---
 .../GraphicsDriver/NVAPI/NvapiUnicodeString.cs     | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs

(limited to 'Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs')

diff --git a/Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs b/Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs
new file mode 100644
index 00000000..bfa039b8
--- /dev/null
+++ b/Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs
@@ -0,0 +1,42 @@
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Ryujinx.Common.GraphicsDriver.NVAPI
+{
+    [StructLayout(LayoutKind.Sequential, Pack = 4)]
+    public unsafe struct NvapiUnicodeString
+    {
+        public fixed byte Data[4096];
+
+        public NvapiUnicodeString(string text)
+        {
+            Set(text);
+        }
+
+        public string Get()
+        {
+            fixed (byte* data = Data)
+            {
+                string text = Encoding.Unicode.GetString(data, 4096);
+
+                int index = text.IndexOf('\0');
+                if (index > -1)
+                {
+                    text = text.Remove(index);
+                }
+
+                return text;
+            }
+        }
+
+        public void Set(string text)
+        {
+            text += '\0';
+            fixed (char* textPtr = text)
+            fixed (byte* data = Data)
+            {
+                int written = Encoding.Unicode.GetBytes(textPtr, text.Length, data, 4096);
+            }
+        }
+    }
+}
-- 
cgit v1.2.3-70-g09d2


From 3f126487abc94cacc7ffab59b2a87b270d3cfe15 Mon Sep 17 00:00:00 2001
From: riperiperi <rhy3756547@hotmail.com>
Date: Wed, 14 Apr 2021 23:27:12 +0100
Subject: Data should not be public for nvapi unicode string

---
 Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs')

diff --git a/Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs b/Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs
index bfa039b8..6bbff2de 100644
--- a/Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs
+++ b/Ryujinx.Common/GraphicsDriver/NVAPI/NvapiUnicodeString.cs
@@ -6,7 +6,7 @@ namespace Ryujinx.Common.GraphicsDriver.NVAPI
     [StructLayout(LayoutKind.Sequential, Pack = 4)]
     public unsafe struct NvapiUnicodeString
     {
-        public fixed byte Data[4096];
+        private fixed byte _data[4096];
 
         public NvapiUnicodeString(string text)
         {
@@ -15,7 +15,7 @@ namespace Ryujinx.Common.GraphicsDriver.NVAPI
 
         public string Get()
         {
-            fixed (byte* data = Data)
+            fixed (byte* data = _data)
             {
                 string text = Encoding.Unicode.GetString(data, 4096);
 
@@ -33,7 +33,7 @@ namespace Ryujinx.Common.GraphicsDriver.NVAPI
         {
             text += '\0';
             fixed (char* textPtr = text)
-            fixed (byte* data = Data)
+            fixed (byte* data = _data)
             {
                 int written = Encoding.Unicode.GetBytes(textPtr, text.Length, data, 4096);
             }
-- 
cgit v1.2.3-70-g09d2