From e46b671875ccdefc809d4fc4cc8982ea4ff4adab Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 9 May 2024 19:16:26 -0400 Subject: [PATCH] Cleanup IntPtr casts --- src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs | 9 +++++---- src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs | 4 ++-- src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index 60638c647..00b3a439a 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -7,6 +7,7 @@ using Ryujinx.Graphics.OpenGL.Queries; using Ryujinx.Graphics.Shader.Translation; using Silk.NET.OpenGL.Legacy.Extensions.ARB; using System; +using System.Runtime.InteropServices; using Sampler = Ryujinx.Graphics.OpenGL.Image.Sampler; namespace Ryujinx.Graphics.OpenGL @@ -247,11 +248,11 @@ namespace Ryujinx.Graphics.OpenGL Api.ClampColor(ClampColorTargetARB.FragmentColorArb, ClampColorModeARB.False); } - private void PrintGpuInformation() + private unsafe void PrintGpuInformation() { - GpuVendor = Api.GetString(StringName.Vendor); - GpuRenderer = Api.GetString(StringName.Renderer); - GpuVersion = Api.GetString(StringName.Version); + GpuVendor = Marshal.PtrToStringAnsi((IntPtr)Api.GetString(StringName.Vendor)); + GpuRenderer = Marshal.PtrToStringAnsi((IntPtr)Api.GetString(StringName.Renderer)); + GpuVersion = Marshal.PtrToStringAnsi((IntPtr)Api.GetString(StringName.Version)); Logger.Notice.Print(LogClass.Gpu, $"{GpuVendor} {GpuRenderer} ({GpuVersion})"); } diff --git a/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs b/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs index 181799d88..050a54370 100644 --- a/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs +++ b/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs @@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.OpenGL _api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle.ToUInt32()); void* ptr = _api.MapBufferRange(BufferTargetARB.CopyWriteBuffer, IntPtr.Zero, (uint)size, MapBufferAccessMask.ReadBit | MapBufferAccessMask.PersistentBit); - _maps[handle] = new IntPtr(ptr); + _maps[handle] = (IntPtr)ptr; } public void Unmap(BufferHandle handle) @@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.OpenGL _api.BindBuffer(BufferTargetARB.CopyWriteBuffer, _copyBufferHandle); _api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)requiredSize, IntPtr.Zero, BufferStorageMask.MapReadBit | BufferStorageMask.MapPersistentBit); - _bufferMap = new IntPtr(_api.MapBufferRange(BufferTargetARB.CopyWriteBuffer, IntPtr.Zero, (uint)requiredSize, MapBufferAccessMask.ReadBit | MapBufferAccessMask.PersistentBit)); + _bufferMap = (IntPtr)_api.MapBufferRange(BufferTargetARB.CopyWriteBuffer, IntPtr.Zero, (uint)requiredSize, MapBufferAccessMask.ReadBit | MapBufferAccessMask.PersistentBit); } } diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs index f5fc24c4f..ad74b2868 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs @@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries unsafe { - _bufferMap = new IntPtr(_api.MapBufferRange(BufferTargetARB.QueryBuffer, IntPtr.Zero, sizeof(long), MapBufferAccessMask.ReadBit | MapBufferAccessMask.WriteBit | MapBufferAccessMask.PersistentBit)); + _bufferMap = (IntPtr)_api.MapBufferRange(BufferTargetARB.QueryBuffer, IntPtr.Zero, sizeof(long), MapBufferAccessMask.ReadBit | MapBufferAccessMask.WriteBit | MapBufferAccessMask.PersistentBit); } }