From 28c1e118a9a7b8764f1b68d00be7b83f6aa05585 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Sun, 24 Aug 2025 10:23:59 +0900 Subject: [PATCH 1/2] Remove NativeLibraryLoader package --- Directory.Build.props | 1 - src/Veldrid/GraphicsDevice.cs | 1 - src/Veldrid/MTL/MTLGraphicsDevice.cs | 10 +++++----- src/Veldrid/OpenGL/OpenGLGraphicsDevice.cs | 7 +++---- src/Veldrid/Veldrid.csproj | 1 - 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index bd6065370..6345d7732 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,6 @@ 1.0.14 - 1.0.13 2.4.2 diff --git a/src/Veldrid/GraphicsDevice.cs b/src/Veldrid/GraphicsDevice.cs index 68c02ceff..ee20164f8 100644 --- a/src/Veldrid/GraphicsDevice.cs +++ b/src/Veldrid/GraphicsDevice.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Veldrid.D3D11; using Veldrid.MTL; diff --git a/src/Veldrid/MTL/MTLGraphicsDevice.cs b/src/Veldrid/MTL/MTLGraphicsDevice.cs index 88aed3dc1..88817ebfc 100644 --- a/src/Veldrid/MTL/MTLGraphicsDevice.cs +++ b/src/Veldrid/MTL/MTLGraphicsDevice.cs @@ -7,7 +7,6 @@ using System.Runtime.InteropServices; using System.Threading; using Veldrid.MetalBindings; -using NativeLibrary = NativeLibraryLoader.NativeLibrary; namespace Veldrid.MTL { @@ -57,7 +56,7 @@ private static readonly Dictionary s_aot_registered_b private const string unaligned_buffer_copy_pipeline_mac_os_name = "MTL_UnalignedBufferCopy_macOS"; private const string unaligned_buffer_copy_pipelinei_os_name = "MTL_UnalignedBufferCopy_iOS"; private readonly object unalignedBufferCopyPipelineLock = new object(); - private readonly NativeLibrary libSystem; + private readonly IntPtr libSystem; // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable private readonly IntPtr concreteGlobalBlock; @@ -122,8 +121,8 @@ public MtlGraphicsDevice( if (MetalFeatures.IsMacOS) { - libSystem = new NativeLibrary("libSystem.dylib"); - concreteGlobalBlock = libSystem.LoadFunction("_NSConcreteGlobalBlock"); + libSystem = NativeLibrary.Load("libSystem.dylib"); + concreteGlobalBlock = NativeLibrary.GetExport(libSystem, "_NSConcreteGlobalBlock"); completionHandler = OnCommandBufferCompleted; displayLink = new MtlcvDisplayLink(); } @@ -325,7 +324,8 @@ protected override void PlatformDispose() lock (s_aot_registered_blocks) s_aot_registered_blocks.Remove(completionBlockLiteral); - libSystem?.Dispose(); + NativeLibrary.Free(libSystem); + Marshal.FreeHGlobal(completionBlockDescriptor); Marshal.FreeHGlobal(completionBlockLiteral); diff --git a/src/Veldrid/OpenGL/OpenGLGraphicsDevice.cs b/src/Veldrid/OpenGL/OpenGLGraphicsDevice.cs index 3539e8ec9..26637cc8d 100644 --- a/src/Veldrid/OpenGL/OpenGLGraphicsDevice.cs +++ b/src/Veldrid/OpenGL/OpenGLGraphicsDevice.cs @@ -13,7 +13,6 @@ using static Veldrid.OpenGLBindings.OpenGLNative; using static Veldrid.OpenGL.OpenGLUtil; using static Veldrid.OpenGL.EGL.EglNative; -using NativeLibrary = NativeLibraryLoader.NativeLibrary; namespace Veldrid.OpenGL { @@ -588,9 +587,9 @@ private void initializeUIView(GraphicsDeviceOptions options, IntPtr uIViewPtr) eaglLayer.Frame = uiView.frame; uiView.layer.addSublayer(eaglLayer.NativePtr); - var glesLibrary = new NativeLibrary("/System/Library/Frameworks/OpenGLES.framework/OpenGLES"); + IntPtr glesLibrary = NativeLibrary.Load("/System/Library/Frameworks/OpenGLES.framework/OpenGLES"); - Func getProcAddress = name => glesLibrary.LoadFunction(name); + Func getProcAddress = name => NativeLibrary.GetExport(glesLibrary, name); LoadAllFunctions(eaglContext.NativePtr, getProcAddress, true); @@ -728,7 +727,7 @@ private void initializeUIView(GraphicsDeviceOptions options, IntPtr uIViewPtr) eaglLayer.RemoveFromSuperlayer(); eaglLayer.Release(); eaglContext.Release(); - glesLibrary.Dispose(); + NativeLibrary.Free(glesLibrary); }; var platformInfo = new OpenGLPlatformInfo( diff --git a/src/Veldrid/Veldrid.csproj b/src/Veldrid/Veldrid.csproj index a09d0bb1c..4f622afb4 100644 --- a/src/Veldrid/Veldrid.csproj +++ b/src/Veldrid/Veldrid.csproj @@ -17,7 +17,6 @@ - From 25e8565f7011a5e4c98c2c74ad2a19e6cd7900ff Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Sun, 24 Aug 2025 10:34:50 +0900 Subject: [PATCH 2/2] Remove unnecessary sourcelink include --- Directory.Build.props | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6345d7732..6a476e6d9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -27,12 +27,6 @@ true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - - all - runtime; build; native; contentfiles; analyzers - - 3.4.255