From a9d0dd389301fd85325e0f9cf34c7092a82bea57 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 9 May 2024 19:34:19 -0400 Subject: [PATCH] Convert GetBinary --- src/Ryujinx.Graphics.OpenGL/Program.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Ryujinx.Graphics.OpenGL/Program.cs b/src/Ryujinx.Graphics.OpenGL/Program.cs index 7938ac906..dbfaa76fa 100644 --- a/src/Ryujinx.Graphics.OpenGL/Program.cs +++ b/src/Ryujinx.Graphics.OpenGL/Program.cs @@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.OpenGL { fixed (byte* ptr = code) { - _api.ProgramBinary(Handle, binaryFormat, (IntPtr)ptr, code.Length - 4); + _api.ProgramBinary(Handle, (GLEnum)binaryFormat, (IntPtr)ptr, (uint)code.Length - 4); } } } @@ -138,17 +138,21 @@ namespace Ryujinx.Graphics.OpenGL return _status; } - public byte[] GetBinary() + public unsafe byte[] GetBinary() { _api.GetProgram(Handle, ProgramPropertyARB.ProgramBinaryLength, out int size); - byte[] data = new byte[size + 4]; + Span data = stackalloc byte[size]; + GLEnum binFormat; - _api.GetProgramBinary(Handle, (uint)size, out _, out GLEnum binFormat, data); + fixed (byte* ptr = data) + { + _api.GetProgramBinary(Handle, (uint)size, out _, out binFormat, ptr); + } - BinaryPrimitives.WriteInt32LittleEndian(data.AsSpan(size, 4), (int)binFormat); + BinaryPrimitives.WriteInt32LittleEndian(data, (int)binFormat); - return data; + return data.ToArray(); } private void DeleteShaders()